Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
MMI-UnitTest-Version_0.74
Browse files Browse the repository at this point in the history
  • Loading branch information
BingyuLiu committed Jun 23, 2016
1 parent aec79b3 commit 8d2644b
Show file tree
Hide file tree
Showing 12 changed files with 2,341 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="UnitTests\TestData\dmtftypes.mof" />
<None Include="UnitTests\TestData\dscinstance.mof" />
<None Include="UnitTests\TestData\dscschema.mof" />
<None Include="UnitTests\TestData\mintinstance.mof" />
<None Include="UnitTests\TestData\mintschema.mof" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\test\Microsoft.Management.Infrastructure.Tests\AssemblyInfo.cs">
Expand Down Expand Up @@ -144,6 +149,18 @@
<Compile Include="..\..\..\test\Microsoft.Management.Infrastructure.Tests\SerializationTests\CimMofDeserializerTests.cs">
<Link>SerializationTests\CimMofDeserializerTests.cs</Link>
</Compile>
<Compile Include="..\..\..\test\Microsoft.Management.Infrastructure.Tests\UnitTests\CimInstanceTest.cs">
<Link>UnitTests\CimInstanceTest.cs</Link>
</Compile>
<Compile Include="..\..\..\test\Microsoft.Management.Infrastructure.Tests\UnitTests\CimMofDeserializerTest.cs">
<Link>UnitTests\CimMofDeserializerTest.cs</Link>
</Compile>
<Compile Include="..\..\..\test\Microsoft.Management.Infrastructure.Tests\UnitTests\CimSessionTest.cs">
<Link>UnitTests\CimSessionTest.cs</Link>
</Compile>
<Compile Include="..\..\..\test\Microsoft.Management.Infrastructure.Tests\UnitTests\CimClassTest.cs">
<Link>UnitTests\CimClassTest.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;
using Microsoft.Management.Infrastructure.Native;

namespace MMI.Tests
{
Expand Down Expand Up @@ -61,7 +55,7 @@ internal static void NotNull<T>(T actual) where T : class
{
Xunit.Assert.NotNull(actual);
}

internal static void Null<T>(T actual) where T : class
{
Xunit.Assert.Null(actual);
Expand Down
34 changes: 31 additions & 3 deletions test/Microsoft.Management.Infrastructure.Tests/Helpers/Helpers.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace MMI.Tests
{
Expand Down Expand Up @@ -33,5 +31,35 @@ public static string GetStringRepresentationOfSerializedData(byte[] data)
return Encoding.ASCII.GetString(data);
#endif
}

/// <summary>
/// convert string to byte[]
/// </summary>
/// <returns></returns>
public static byte[] GetBytesFromString(string str)
{
System.Text.UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(str);
}

/// <summary>
/// Read file content to byte[]
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static byte[] GetBytesFromFile(string filePath)
{
using (FileStream fs = File.OpenRead(filePath))
{
byte[] bytes = new byte[fs.Length];
fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
// FileStream.close method is not supported in .net core currently.
#if !_LINUX
fs.Close();
#else
#endif
return bytes;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*============================================================================
* Copyright (C) Microsoft Corporation, All rights reserved.
*=============================================================================
*/

namespace Microsoft.Management.Infrastructure.UnitTests
{
using Microsoft.Management.Infrastructure;
using Microsoft.Management.Infrastructure.Native;
using System;
using MMI.Tests;
using Xunit;

public class CimClassTest
{
[TDDFact]
public void TODO()
{
}
}
}
1,270 changes: 1,270 additions & 0 deletions test/Microsoft.Management.Infrastructure.Tests/UnitTests/CimInstanceTest.cs

Large diffs are not rendered by default.

Loading

0 comments on commit 8d2644b

Please sign in to comment.