Skip to content

Commit

Permalink
Styling changes and SDS mapping (#14)
Browse files Browse the repository at this point in the history
Add tests for report server. Fixed shared datasource mapping. Applied suggested style.
  • Loading branch information
gboreki authored Aug 8, 2019
1 parent 99db48c commit 2973310
Show file tree
Hide file tree
Showing 17 changed files with 523 additions and 383 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ This is a Tool that takes files from the report server and convert the shared co
It will save all the converted files to local disk and display the status of each file
The status would be displayed in the command window as well as a file called *ConversionLog.txt*

**NOTE:** it will **NOT** take the correpond datasource or dataset down and thus will **NOT** push any datasource or dataset to PBI Workspace.

---
## Input details:

Expand Down
8 changes: 5 additions & 3 deletions RdlMigration.UnitTest/PowerBIClientWrapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ public void TestClient_NotPremiumWorkspace()
private PowerBIClientWrapper CreateMockOperations(string workspaceName)
{
var importOperationResult = System.Threading.Tasks.Task.FromResult(new HttpOperationResponse<Import>());
var groupList = new List<Group>();
groupList.Add(new Group(new Guid(), "testWorkspace"));
groupList.Add(new Group(new Guid(), "NonPremiumWorkspace", isOnDedicatedCapacity: false));
var groupList = new List<Group>
{
new Group(new Guid(), "testWorkspace"),
new Group(new Guid(), "NonPremiumWorkspace", isOnDedicatedCapacity: false)
};
var groupOperationResult = System.Threading.Tasks.Task.FromResult(new HttpOperationResponse<Groups>()
{
Body = new Groups()
Expand Down
5 changes: 2 additions & 3 deletions RdlMigration.UnitTest/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions RdlMigration.UnitTest/RdlFileIOTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright (c) 2019 Microsoft Corporation. All Rights Reserved.
// Licensed under the MIT License (MIT)

using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using Microsoft.PowerBI.Api.V2;
using Microsoft.PowerBI.Api.V2.Models;
using Microsoft.Rest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using RdlMigration.ReportServerApi;

namespace RdlMigration.UnitTest
{
[TestClass]
public class RdlFileIOTests
{
[TestMethod]
public void TestFromServer_SharedDataSourceNamesAreKept()
{
var mockServer = new Mock<IReportingService2010>();
var mockDataSource = new ItemReferenceData
{
Name = "DataSource1",
Reference = "/reference/ds1",
ReferenceType = "DataSource"
};

mockServer.Setup(p => p.GetItemReferences(It.IsAny<string>(), "DataSource")).Returns(new ItemReferenceData[] { mockDataSource });
var sut = new RdlFileIO(mockServer.Object);
var references = sut.GetDataSourceReference("path");

Assert.AreEqual(1, references.Count);
Assert.AreEqual("DataSource1", references[0].Name);
}

[TestMethod]
public void TestFromServer_SharedDataSetDataSourceNamesAreRenamed()
{
var mockServer = new Mock<IReportingService2010>();
var mockDataSource = new ItemReferenceData
{
Name = "DataSource1",
Reference = "/reference/ds1",
ReferenceType = "DataSource"
};

var mockDataSource2 = new ItemReferenceData
{
Name = "DataSource2",
Reference = "/reference/ds2",
ReferenceType = "DataSource"
};

var mockDataSet = new ItemReferenceData
{
Name = "Dataset1",
Reference = "/reference/ds2",
ReferenceType = "DataSource"
};

mockServer.Setup(p => p.GetItemReferences("/report", "DataSource"))
.Returns(new ItemReferenceData[] { mockDataSource });

mockServer.Setup(p => p.GetItemReferences("/reference/ds2", "DataSource"))
.Returns(new ItemReferenceData[] { mockDataSource2 });

mockServer.Setup(p => p.GetItemReferences(It.IsAny<string>(), "DataSet"))
.Returns(new ItemReferenceData[] { mockDataSet });

var sut = new RdlFileIO(mockServer.Object);
var references = sut.GetDataSourceReference("/report");

Assert.AreEqual(2, references.Count);
Assert.AreEqual("DataSource1", references[0].Name);
Assert.IsTrue(references[1].Name.Contains("ds2"));
}
}
}
5 changes: 4 additions & 1 deletion RdlMigration.UnitTest/RdlMigration.UnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RdlMigration.UnitTest</RootNamespace>
<AssemblyName>RdlMigration.UnitTest</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
Expand All @@ -19,6 +19,7 @@
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -69,11 +70,13 @@
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Web.Services" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="FileTest.cs" />
<Compile Include="RdlFileIOTests.cs" />
<Compile Include="PowerBIClientWrapperTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
Expand Down
8 changes: 4 additions & 4 deletions RdlMigration.UnitTest/app.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup></configuration>
Loading

0 comments on commit 2973310

Please sign in to comment.