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

Commit

Permalink
Merge pull request #17 from PowerShell/johnliu-mmi-unittests-new-1
Browse files Browse the repository at this point in the history
  • Loading branch information
BingyuLiu authored Jun 24, 2016
2 parents aec79b3 + ab2763f commit 7451a3e
Show file tree
Hide file tree
Showing 12 changed files with 2,336 additions and 11 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,15 @@
<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>
</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
36 changes: 32 additions & 4 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 All @@ -27,11 +25,41 @@ public static Y GetPrivateVariable<X, Y>(this X self, string name)

public static string GetStringRepresentationOfSerializedData(byte[] data)
{
#if !_LINUX
#if !_CORECLR
return Encoding.Unicode.GetString(data);
#else
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()
{
}
}
}
Loading

0 comments on commit 7451a3e

Please sign in to comment.