diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Adds.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Adds.cs
deleted file mode 100644
index aaaea54..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Adds.cs
+++ /dev/null
@@ -1,8 +0,0 @@
- public class Adds
- {
-
- public static int Add(int x, int y)
-{
- return x+y;
-}
- }
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app-routing.module.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app-routing.module.ts
index 190dd88..2b26472 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app-routing.module.ts
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app-routing.module.ts
@@ -4,15 +4,13 @@ import { MsalGuard } from "@azure/msal-angular";
import { HomeComponent } from "./components/home/home.component";
import { ProfileComponent } from "./components/profile/profile.component";
import { UserComponent } from "./components/users/users.component";
-import { utCreateComponent } from "./components/utCreate/utCreate.component";
-import { utExecuteComponent } from "./components/utExecute/utExecute.component";
-import { utTreeViewTestComponent } from "./components/utTreeViewTest/utTreeViewTest.component";
import { RoleGuard } from "./shared/guards/role.guard";
+import { UnitTestsComponent } from "./components/unit-tests/unit-tests.component";
const routes: Routes = [
{ path: "", pathMatch: "full", redirectTo: "/unittests" },
{ path: "profile", component: ProfileComponent, canActivate: [MsalGuard] },
- { path: "unittests", component: utTreeViewTestComponent, canActivate: [MsalGuard] },
+ { path: "unittests", component: UnitTestsComponent, canActivate: [MsalGuard] },
];
@NgModule({
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app.module.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app.module.ts
index 1a0e5d1..412e655 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app.module.ts
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app.module.ts
@@ -64,19 +64,14 @@ import { LayoutService } from "./shared/services/layout.service";
import { DxTreeListModule } from "devextreme-angular";
import { RoleGuard } from "./shared/guards/role.guard";
import { Router } from "@angular/router";
-import { utCreateComponent } from "./components/utCreate/utCreate.component";
-import { utExecuteComponent } from "./components/utExecute/utExecute.component";
-import { UnitTestService } from "./shared/services/UnitTest.service";
-import { UserStoryService } from "./shared/services/UserStory.service";
-import { utTreeViewTestComponent } from "./components/utTreeViewTest/utTreeViewTest.component";
+import { UnitTestService } from "./shared/services/unit-test.service";
+import { UserStoryService } from "./shared/services/user-story.service";
import { WorkspaceService } from "./shared/services/workspace.service";
-import { TabularModelService } from "./shared/services/TabularModel.service";
-import { StructurService } from "./shared/services/structur.service";
+import { TabularModelService } from "./shared/services/tabular-model.service";
import { DxoHideEventModule } from "devextreme-angular/ui/nested";
-import { HistoryService } from "./shared/services/history.service";
import { SideNavigationMenuComponent } from "./components/side-navigation-menu/side-navigation-menu.component";
-
-
+import { UnitTestsComponent } from "./components/unit-tests/unit-tests.component";
+import { GetFirstElementPipe } from "./shared/pipes/get-first-element.pipe";
export function initializeAppConfig(appConfig: AppConfig, router: Router) {
return () => appConfig.load();
@@ -88,10 +83,9 @@ export function initializeAppConfig(appConfig: AppConfig, router: Router) {
HomeComponent,
ProfileComponent,
UserComponent,
- utCreateComponent,
- utExecuteComponent,
- utTreeViewTestComponent,
- SideNavigationMenuComponent
+ UnitTestsComponent,
+ SideNavigationMenuComponent,
+ GetFirstElementPipe
],
imports: [
BrowserModule.withServerTransition({ appId: "ng-cli-universal" }),
@@ -162,8 +156,6 @@ export function initializeAppConfig(appConfig: AppConfig, router: Router) {
UserStoryService,
WorkspaceService,
TabularModelService,
- StructurService,
- HistoryService,
],
bootstrap: [AppComponent, MsalRedirectComponent],
})
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.html
index 30ae345..5951139 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.html
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.html
@@ -20,10 +20,18 @@
-
First Name: {{user?.Firstname}}
-
Last Name: {{user?.Lastname}}
-
Email: {{user?.Email}}
-
Azure AD Id: {{user?.MsId}}
-
Roles: {{roles}}
+
First Name: {{ user?.Firstname }}
+
Last Name: {{ user?.Lastname }}
+
Email: {{ user?.Email }}
+
Azure AD Id: {{ user?.MsId }}
+
Roles: {{ roles }}
+
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.ts
index 7dbb48c..630a5d7 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.ts
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.ts
@@ -9,6 +9,7 @@ import {
import { Subject } from "rxjs";
import { filter, takeUntil } from "rxjs/operators";
import { User } from "src/app/shared/models/user.model";
+import { LayoutService, NotificationType } from "src/app/shared/services/layout.service";
import { ODataService } from "src/app/shared/services/odata.service";
import { UserService } from "src/app/shared/services/user.service";
@@ -23,8 +24,9 @@ export class ProfileComponent implements OnInit {
roles: string;
constructor(
- private userService: UserService
- ) {}
+ private userService: UserService,
+ private layoutService: LayoutService
+ ) { }
ngOnInit(): void {
this.getUserInformation();
@@ -33,9 +35,9 @@ export class ProfileComponent implements OnInit {
});
}
- private getUserInformation(){
+ private getUserInformation() {
this.isLoggedIn = this.userService.isLogggedIn;
- if(this.isLoggedIn){
+ if (this.isLoggedIn) {
this.user = this.userService.currentDbUserWithTenant;
this.roles = this.userService.currentUserRoles?.join(", ");
}
@@ -48,4 +50,9 @@ export class ProfileComponent implements OnInit {
async logout() {
await this.userService.logout();
}
+
+ public onClickResetGridSettings(e): void {
+ localStorage.removeItem("atPowerBiUnitTestPortal_UnitTests_TreeListState");
+ this.layoutService.notify({ message: "The grid settings have been successfully reset.", type: NotificationType.Success });
+ }
}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.css b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.css
new file mode 100644
index 0000000..a645a87
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.css
@@ -0,0 +1,15 @@
+::ng-deep .dx-treelist-search-panel {
+ margin: 0 !important;
+}
+
+::ng-deep .hide-checkbox .dx-select-checkbox{
+ display: none;
+}
+
+::ng-deep .hide-checkbox .dx-treelist-icon-container{
+ padding-right: 0px;
+}
+
+::ng-deep dx-select-box {
+ margin-bottom: 15px;
+}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.html
new file mode 100644
index 0000000..659ed08
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.html
@@ -0,0 +1,119 @@
+Unit Tests
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ data.value }}
+ error durring
+ execution
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Workspace:
+
+
+ Tabular Model:
+
+
+
+
+
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.ts
new file mode 100644
index 0000000..d4c5fcc
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.ts
@@ -0,0 +1,530 @@
+import { Component, OnInit, ViewChild } from "@angular/core";
+import { DxDataGridComponent, DxTreeListComponent } from "devextreme-angular";
+import CustomStore from "devextreme/data/custom_store";
+import DataSource from "devextreme/data/data_source";
+import { ClickEvent } from "devextreme/ui/button";
+import { ToolbarPreparingEvent } from "devextreme/ui/tree_list";
+import { UserStory } from "src/app/shared/models/user-story.model";
+import { UnitTestService } from "src/app/shared/services/unit-test.service";
+import { confirm } from 'devextreme/ui/dialog';
+import {
+ LayoutParameter,
+ LayoutService,
+ NotificationType,
+} from "src/app/shared/services/layout.service";
+import { UserStoryService } from "src/app/shared/services/user-story.service";
+import { WorkspaceService } from "src/app/shared/services/workspace.service";
+import { UnitTest } from "src/app/shared/models/unit-test.model";
+import ODataContext from "devextreme/data/odata/context";
+import { TabularModelService } from "src/app/shared/services/tabular-model.service";
+
+@Component({
+ selector: "app-unit-tests",
+ templateUrl: "./unit-tests.component.html",
+ styleUrls: ["./unit-tests.component.css"],
+})
+export class UnitTestsComponent implements OnInit {
+ public dataSourceWorkspaces: DataSource;
+ public dataSourceWorkspacesOdata: DataSource;
+ public dataSourceTabularModels: DataSource;
+ @ViewChild(DxTreeListComponent, { static: false })
+ treeList: DxDataGridComponent;
+
+ public isVisibleEditUnitTest: boolean = false;
+ public isVisibleEditUserStory: boolean = false;
+ public isVisibleCopyUserStory: boolean = false;
+ public popupTitle: string = "";
+
+ public userStoryToEdit: UserStory = {};
+ public unitTestToEdit: UnitTest = {};
+ public copyUserStoryConfig: { workspaceId?: number, tabularModelId?: number, userStoryId?: number, tabularModelToExclude?: number } = {};
+
+ public resultTypeItems: string[] = ["String", "Float", "Date", "Percentage"];
+ public dateTimeFormatItems: string[] = ["UTC", "CET"];
+ public floatSeparatorItems: string[] = ["Use Seperators", "Dont use Sperators"];
+ public decimalPlacesItems: string[] = ["1", "2", "3", "4", "5"];
+
+ constructor(
+ private unitTestService: UnitTestService,
+ private userStoryService: UserStoryService,
+ private workspaceService: WorkspaceService,
+ private tabularModelService: TabularModelService,
+ private layoutService: LayoutService
+ ) {
+ this.onClickExecuteUnitTests = this.onClickExecuteUnitTests.bind(this);
+ this.onClickAddUserStory = this.onClickAddUserStory.bind(this);
+ this.onClickEditUserStory = this.onClickEditUserStory.bind(this);
+ this.onClickDeleteUserStory = this.onClickDeleteUserStory.bind(this);
+ this.onClickAddUnitTest = this.onClickAddUnitTest.bind(this);
+ this.onClickEditUnitTest = this.onClickEditUnitTest.bind(this);
+ this.onClickDeleteUnitTest = this.onClickDeleteUnitTest.bind(this);
+ this.onClickCopyUserStory = this.onClickCopyUserStory.bind(this);
+
+ this.dataSourceWorkspaces = new DataSource({
+ store: new CustomStore({
+ key: "UniqueIdentifier",
+ load: async (loadOptions) => {
+ if (loadOptions.expand == null)
+ loadOptions.expand = new Array();
+ loadOptions.expand.push("TabularModels");
+ loadOptions.expand.push("TabularModels.UserStories");
+ loadOptions.expand.push("TabularModels.UserStories.UnitTests");
+ loadOptions.expand.push("TabularModels.UserStories.UnitTests.TestRuns($top=1;$orderby=TimeStamp desc)");
+ return (this.workspaceService.getStore().load(loadOptions)).then((data) => {
+ data.forEach(e => {
+ delete Object.assign(e, { ["items"]: e["TabularModels"] })["TabularModels"]
+ e["type"] = "Workspace";
+ e["parentId"] = 0;
+ e["items"]?.forEach(ee => {
+ delete Object.assign(ee, { ["items"]: ee["UserStories"] })["UserStories"]
+ ee["type"] = "Tabular Model";
+ ee["parentId"] = e["UniqueIdentifier"];
+ ee["items"]?.forEach(eee => {
+ delete Object.assign(eee, { ["items"]: eee["UnitTests"] })["UnitTests"]
+ eee["type"] = "User Story";
+ eee["parentId"] = ee["UniqueIdentifier"];
+ eee["items"]?.forEach(eeee => {
+ eeee["type"] = "Unit Test";
+ eeee["parentId"] = eee["UniqueIdentifier"];
+ })
+ })
+ })
+ });
+ });
+ }
+ })
+ });
+
+ this.dataSourceWorkspacesOdata = new DataSource({
+ store: this.workspaceService.getStore(),
+ sort: [{ selector: "Name", desc: false }]
+ });
+ }
+
+ ngOnInit(): void { }
+
+ public onClickPullWorkspaces(e: ClickEvent): void {
+ this.layoutService.change(LayoutParameter.ShowLoading, true);
+ this.workspaceService
+ .pullWorkspaces()
+ .then(() => {
+ this.treeList.instance.refresh();
+ this.layoutService.notify({
+ message: "Workspaces pulled successfully",
+ type: NotificationType.Success,
+ });
+ })
+ .catch((error: Error) => this.layoutService.notify({
+ message: error.message ? `Can not pull workspaces: ${error.message}` : "Error while pulling workspaces",
+ type: NotificationType.Error,
+ }))
+ .finally(() =>
+ this.layoutService.change(LayoutParameter.ShowLoading, false)
+ );
+ }
+
+ public onToolbarPreparingTreeList(e: ToolbarPreparingEvent): void {
+ let toolbarItems = e.toolbarOptions.items;
+
+ toolbarItems.unshift({
+ widget: "dxButton",
+ options: {
+ icon: "refresh",
+ stylingMode: "contained",
+ type: "normal",
+ hint: "Refresh Applications",
+ onClick: this.onClickRefresh.bind(this),
+ },
+ location: "after",
+ });
+
+ toolbarItems.unshift({
+ widget: "dxButton",
+ options: {
+ icon: "clear",
+ stylingMode: "contained",
+ type: "normal",
+ hint: "Clear Selection",
+ onClick: this.onClickClearSelection.bind(this),
+ },
+ location: "after",
+ });
+
+ toolbarItems.unshift({
+ widget: "dxButton",
+ options: {
+ icon: "trash",
+ stylingMode: "contained",
+ type: "danger",
+ hint: "Delete Unit Tests",
+ text: "Delete Unit Tests",
+ onClick: this.onClickDeleteMultipleUnitTests.bind(this),
+ },
+ location: "after",
+ });
+
+ toolbarItems.unshift({
+ widget: "dxButton",
+ options: {
+ icon: "runner",
+ stylingMode: "contained",
+ type: "success",
+ hint: "Execute Unit Tests",
+ text: "Execute Unit Tests",
+ onClick: this.onClickExecuteMultipleUnitTests.bind(this),
+ },
+ location: "after",
+ });
+
+ toolbarItems.unshift({
+ widget: "dxButton",
+ options: {
+ icon: "download",
+ text: "Pull Workspaces",
+ stylingMode: "contained",
+ type: "normal",
+ onClick: this.onClickPullWorkspaces.bind(this),
+ },
+ location: "before",
+ });
+ }
+
+ public onCellPreparedTreeList(e: any): void {
+ if (e.rowType === "data" && e.row.data.type == "Unit Test" && e.column.dataField === "TestRuns[0].Result") {
+ e.cellElement.style.color = e.row.data?.TestRuns[0]?.WasPassed ? "green" : "red";
+ }
+ }
+
+ public onRowDbClickTreeList(e: any): void {
+ if (e.rowType === "data" && e.data.type == "Unit Test") {
+ this.openEditUnitTestPopup(e.data);
+ }
+ else if (e.rowType == "data" && e.data.type == "User Story") {
+ this.openEditUserStoryPopup(e.data);
+ }
+ }
+
+ public onRowPreparedTreeList(e: any): void {
+ if (e.rowType == "data" && e.data.type != "Unit Test" || e.rowType == "header") {
+ e.rowElement.classList.add("hide-checkbox");
+ }
+ }
+
+ public onClickCopyUserStory(e: any): void {
+ this.copyUserStoryConfig = {};
+ this.copyUserStoryConfig.tabularModelToExclude = e.row.data.TabularModel;
+ this.copyUserStoryConfig.userStoryId = e.row.data.Id;
+ this.isVisibleCopyUserStory = true;
+ }
+
+ public onClickSaveCopyUserStory(e: any): void {
+ this.layoutService.change(LayoutParameter.ShowLoading, true);
+ this.userStoryService.copyToOtherTabularModel(this.copyUserStoryConfig.userStoryId, this.copyUserStoryConfig.tabularModelId)
+ .then(() => {
+ this.layoutService.notify({
+ type: NotificationType.Success,
+ message: "The user story was copied successfully."
+ });
+ this.isVisibleCopyUserStory = false;
+ this.copyUserStoryConfig = {};
+ this.treeList.instance.refresh();
+ })
+ .catch((error: Error) => this.layoutService.notify({
+ type: NotificationType.Error,
+ message: error?.message ? `The user story could not be copied.: ${error.message}` : "The user story could not be copied."
+ }))
+ .then(() => { this.layoutService.change(LayoutParameter.ShowLoading, false); });
+ }
+
+ public onValueChangeCopyUserStoryWorkspace(e: any): void {
+ this.copyUserStoryConfig.workspaceId = e.value.Id;
+ this.dataSourceTabularModels = new DataSource({
+ store: this.tabularModelService.getStore(),
+ filter: [["Workspace", "=", e.value.Id], "and", ["Id", "<>", this.copyUserStoryConfig.tabularModelToExclude]],
+ sort: [{ selector: "Name", desc: false }],
+ });
+ }
+
+ public onValueChangeCopyUserStoryTabularModel(e: any): void {
+ this.copyUserStoryConfig.tabularModelId = e.value.Id;
+ }
+
+ public onClickClearSelection(e: any): void {
+ this.treeList.instance.clearSelection();
+ }
+
+ public onClickExecuteMultipleUnitTests(e: any): void {
+ let data = this.treeList.instance.getSelectedRowsData();
+ let unitTestIds = data.filter((e: any) => e.type == "Unit Test").map((e: any) => e.Id);
+ if (unitTestIds.length == 0) {
+ this.layoutService.notify({
+ type: NotificationType.Info,
+ message: "No unit tests selected for execution."
+ });
+ return;
+ }
+ this.executeUnitTest(unitTestIds);
+ }
+
+ public onClickExecuteUnitTests(e: any): void {
+ let unitTestIdsToExecute = [];
+ if (e.row.data.type == "Unit Test")
+ unitTestIdsToExecute = [e.row.data.Id];
+ else if (e.row.data.type == "User Story")
+ unitTestIdsToExecute = e.row.node.children.map((e: any) => e.data.Id);
+ else if (e.row.data.type == "Tabular Model")
+ unitTestIdsToExecute = e.row.node.children.flatMap((e: any) => e.children.map((ee: any) => ee.data.Id));
+ else if (e.row.data.type == "Workspace")
+ unitTestIdsToExecute = e.row.node.children.flatMap((e: any) => e.children.flatMap((ee: any) => ee.children.map((eee: any) => eee.data.Id)));
+
+ this.executeUnitTest(unitTestIdsToExecute);
+ }
+
+ public onClickRefresh(e: ClickEvent): void {
+ this.treeList.instance.refresh();
+ }
+
+ public onClickAddUnitTest(e: any): void {
+ this.popupTitle = "Add Unit Test";
+ this.unitTestToEdit = {};
+ this.unitTestToEdit.UserStory = e.row.data.Id;
+ this.isVisibleEditUnitTest = true;
+ }
+
+ public onClickEditUnitTest(e: any): void {
+ this.openEditUnitTestPopup(e.row.data);
+ }
+
+ public onClickAddUserStory(e: any): void {
+ this.popupTitle = "Add User Story";
+ this.userStoryToEdit = {};
+ this.userStoryToEdit.TabularModel = e.row.data.Id;
+ this.isVisibleEditUserStory = true;
+ }
+
+ public onClickEditUserStory(e: any): void {
+ this.openEditUserStoryPopup(e.row.data);
+ }
+
+ public onClickDeleteUserStory(e: any): void {
+ let result = confirm("Are you sure you want to delete this user story (including all unit tests)?", "Delete User Story");
+ result.then((dialogResult) => {
+ if (dialogResult) {
+ this.layoutService.change(LayoutParameter.ShowLoading, true);
+ this.userStoryService.remove(e.row.data.Id)
+ .then(() => this.layoutService.notify({
+ type: NotificationType.Success,
+ message: "The user story was deleted successfully."
+ }))
+ .catch((error: Error) => this.layoutService.notify({
+ type: NotificationType.Error,
+ message: error?.message ? `The user story could not be deleted: ${error.message}` : "The user story could not be deleted."
+ }))
+ .then(() => {
+ this.treeList.instance.refresh();
+ this.layoutService.change(LayoutParameter.ShowLoading, false);
+ });
+ }
+ });
+ }
+
+ public onClickDeleteMultipleUnitTests(e: any): void {
+ let data = this.treeList.instance.getSelectedRowsData();
+ let unitTestIds = data.filter((e: any) => e.type == "Unit Test").map((e: any) => e.Id);
+ if (unitTestIds.length == 0) {
+ this.layoutService.notify({
+ type: NotificationType.Info,
+ message: "No unit tests selected for deletion."
+ });
+ return;
+ }
+
+ let result = confirm("Are you sure you want to delete these unit tests?", "Delete Unit Tests");
+ result.then((dialogResult) => {
+ if (dialogResult) {
+ this.layoutService.change(LayoutParameter.ShowLoading, true);
+ let promises = [];
+ unitTestIds.forEach((e: any) => {
+ promises.push(this.unitTestService.remove(e));
+ });
+ Promise.all(promises)
+ .then(() => this.layoutService.notify({
+ type: NotificationType.Success,
+ message: "The unit tests were deleted successfully."
+ }))
+ .catch((error: Error) => this.layoutService.notify({
+ type: NotificationType.Error,
+ message: error?.message ? `One or more unit tests could not be deleted: ${error.message}` : "One or more unit tests could not be deleted"
+ }))
+ .then(() => {
+ this.treeList.instance.refresh();
+ this.layoutService.change(LayoutParameter.ShowLoading, false);
+ });
+ }
+ });
+ }
+
+ public onClickDeleteUnitTest(e: any): void {
+ let result = confirm("Are you sure you want to delete this unit test?", "Delete Unit Test");
+ result.then((dialogResult) => {
+ if (dialogResult) {
+ this.layoutService.change(LayoutParameter.ShowLoading, true);
+ this.unitTestService.remove(e.row.data.Id)
+ .then(() => this.layoutService.notify({
+ type: NotificationType.Success,
+ message: "The unit test was deleted successfully."
+ }))
+ .catch((error: Error) => this.layoutService.notify({
+ type: NotificationType.Error,
+ message: error?.message ? `The unit test could not be deleted: ${error.message}` : "The unit test could not be deleted."
+ }))
+ .then(() => {
+ this.treeList.instance.refresh();
+ this.layoutService.change(LayoutParameter.ShowLoading, false);
+ });
+ }
+ });
+ }
+
+ public onClickSaveUnitTest(e: ClickEvent): void {
+ let validation = e.validationGroup.validate();
+ if (validation.isValid == true) {
+ this.layoutService.change(LayoutParameter.ShowLoading, true);
+ let editPromise;
+ if (this.unitTestToEdit.Id != null) {
+ editPromise = this.unitTestService.update(this.unitTestToEdit.Id, { Name: this.unitTestToEdit.Name, DAX: this.unitTestToEdit.DAX, ExpectedResult: this.unitTestToEdit.ExpectedResult, ResultType: this.unitTestToEdit.ResultType, DateTimeFormat: this.unitTestToEdit.DateTimeFormat, FloatSeparators: this.unitTestToEdit.FloatSeparators, DecimalPlaces: this.unitTestToEdit.DecimalPlaces })
+ .then(() => {
+ this.layoutService.notify({
+ type: NotificationType.Success,
+ message: "The unit test has been edited successfully."
+ });
+ this.isVisibleEditUnitTest = false;
+ this.unitTestToEdit = {};
+ this.treeList.instance.refresh();
+ })
+ .catch((error: Error) => this.layoutService.notify({
+ type: NotificationType.Error,
+ message: error?.message ? `The unit test could not be edited: ${error.message}` : "The unit test could not be edited."
+ }))
+
+ }
+ else {
+ editPromise = this.unitTestService.add(this.unitTestToEdit)
+ .then(() => {
+ this.layoutService.notify({
+ type: NotificationType.Success,
+ message: "The new uni test has been created successfully."
+ });
+ this.isVisibleEditUnitTest = false;
+ this.unitTestToEdit = {};
+ this.treeList.instance.refresh();
+ })
+ .catch((error: Error) => this.layoutService.notify({
+ type: NotificationType.Error,
+ message: error?.message ? `The new unit test could not be created: ${error.message}` : "The new unit test could not be created."
+ }))
+ }
+
+ editPromise.then(() => {
+ this.layoutService.change(LayoutParameter.ShowLoading, false);
+ });
+ }
+ }
+
+ public onClickSaveUserStory(e: ClickEvent): void {
+ let validation = e.validationGroup.validate();
+ if (validation.isValid == true) {
+ this.layoutService.change(LayoutParameter.ShowLoading, true);
+ let editPromise;
+ if (this.userStoryToEdit.Id != null) {
+ editPromise = this.userStoryService.update(this.userStoryToEdit.Id, { Name: this.userStoryToEdit.Name })
+ .then(() => {
+ this.layoutService.notify({
+ type: NotificationType.Success,
+ message: "The user story has been edited successfully."
+ });
+ this.isVisibleEditUserStory = false;
+ this.userStoryToEdit = {};
+ this.treeList.instance.refresh();
+ })
+ .catch((error: Error) => this.layoutService.notify({
+ type: NotificationType.Error,
+ message: error?.message ? `The user story could not be edited: ${error.message}` : "The user story could not be edited."
+ }))
+ }
+ else {
+ editPromise = this.userStoryService.add(this.userStoryToEdit)
+ .then(() => {
+ this.layoutService.notify({
+ type: NotificationType.Success,
+ message: "The new user story has been created successfully."
+ });
+ this.isVisibleEditUserStory = false;
+ this.userStoryToEdit = {};
+ this.treeList.instance.refresh();
+ })
+ .catch((error: Error) => this.layoutService.notify({
+ type: NotificationType.Error,
+ message: error?.message ? `The new user story could not be created: ${error.message}` : "The new user story could not be created."
+ }))
+ }
+
+ editPromise.then(() => {
+ this.layoutService.change(LayoutParameter.ShowLoading, false);
+ });
+ }
+ }
+
+ public isWorkspaceRow(e: any): boolean {
+ if (e.row.rowType == "data" && e.row.data.type == "Workspace")
+ return true;
+ return false;
+ }
+
+ public isUnitTestRow(e: any): boolean {
+ if (e.row.rowType == "data" && e.row.data.type == "Unit Test")
+ return true;
+ return false;
+ }
+
+ public isUserStoryRow(e: any): boolean {
+ if (e.row.rowType == "data" && e.row.data.type == "User Story")
+ return true;
+ return false;
+ }
+
+ public isTabularModelRow(e: any): boolean {
+ if (e.row.rowType == "data" && e.row.data.type == "Tabular Model")
+ return true;
+ return false;
+ }
+
+ private openEditUnitTestPopup(unitTest: UnitTest): void {
+ this.popupTitle = "Edit Unit Test";
+ this.unitTestToEdit = structuredClone(unitTest);
+ this.isVisibleEditUnitTest = true;
+ }
+
+ private openEditUserStoryPopup(userStory: UserStory): void {
+ this.popupTitle = "Edit User Story";
+ this.userStoryToEdit = structuredClone(userStory);
+ this.isVisibleEditUserStory = true;
+ }
+
+ private executeUnitTest(ids: number[]): void {
+ this.layoutService.change(LayoutParameter.ShowLoading, true);
+ this.unitTestService.executeMultiple(ids)
+ .then(() => {
+ this.layoutService.notify({
+ type: NotificationType.Success,
+ message: "Unit test(s) executed successfully."
+ });
+ this.treeList.instance.refresh();
+ })
+ .catch((error: Error) => this.layoutService.notify({
+ type: NotificationType.Error,
+ message: error?.message ? `Unit tests could not be executed: ${error.message}` : "Unit tests could not be executed."
+ }))
+ .then(() => { this.layoutService.change(LayoutParameter.ShowLoading, false); });
+ }
+}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.css b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.css
deleted file mode 100644
index 8b13789..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.css
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.html
deleted file mode 100644
index 733a4fc..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.html
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.ts
deleted file mode 100644
index abde3ef..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { Component, OnInit, ViewChild } from "@angular/core";
-import DataSource from "devextreme/data/data_source";
-import { UserService } from "src/app/shared/services/user.service";
-import {
- LayoutParameter,
- LayoutService,
- NotificationType,
-} from "src/app/shared/services/layout.service";
-import { AppConfig } from "src/app/shared/config/app.config";
-import { User } from "src/app/shared/models/user.model";
-import { environment } from "src/environments/environment";
-import { DxDataGridComponent, DxListComponent, DxPopupComponent } from "devextreme-angular";
-import { UnitTestService } from "src/app/shared/services/UnitTest.service";
-import { UnitTest } from "src/app/shared/models/UnitTest.model";
-import * as pbi from 'powerbi-client';
-import { ElementRef } from "@angular/core";
-import notify from "devextreme/ui/notify";
-import { UserStoryService } from "src/app/shared/services/UserStory.service";
-import { UserStory } from "src/app/shared/models/UserStory.model";
-
-
-
-
-@Component({
- selector: "app-utCreate",
- templateUrl: "./utCreate.component.html",
- //styleUrls: ["./utExecute.component.css"],
-})
-export class utCreateComponent{
- dataSourceUserStory: DataSource;
- currentSelectedUnitTest: UserStory;
- @ViewChild(DxDataGridComponent, { static: false }) dataGrid: DxDataGridComponent;
-
-
- constructor(
- private UserStoryService: UserStoryService,
- private layoutService: LayoutService,
- ) {
- this.dataSourceUserStory = new DataSource({
- store: this.UserStoryService.getStore(),
-
- });
-
- }
-}
-
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.css b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.css
deleted file mode 100644
index e69de29..0000000
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.html
deleted file mode 100644
index c85011c..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.html
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-Hallo das ist auch ein Test
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Das Ergebnis lautet :{{ Ergebnis }}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.ts
deleted file mode 100644
index 3240f2d..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { Component, OnInit, ViewChild } from "@angular/core";
-import DataSource from "devextreme/data/data_source";
-import { UserService } from "src/app/shared/services/user.service";
-import {
- LayoutParameter,
- LayoutService,
- NotificationType,
-} from "src/app/shared/services/layout.service";
-import { AppConfig } from "src/app/shared/config/app.config";
-import { User } from "src/app/shared/models/user.model";
-import { environment } from "src/environments/environment";
-import { DxDataGridComponent, DxListComponent, DxPopupComponent } from "devextreme-angular";
-import { UnitTestService } from "src/app/shared/services/UnitTest.service";
-import { UnitTest } from "src/app/shared/models/UnitTest.model";
-import * as pbi from 'powerbi-client';
-import { ElementRef } from "@angular/core";
-import notify from "devextreme/ui/notify";
-import { Structur } from "src/app/shared/models/Structur.model";
-import { HttpClient } from "@angular/common/http";
-
-@Component({
- selector: "app-utExecute",
- templateUrl: "./utExecute.component.html",
- //styleUrls: ["./utExecute.component.css"],
-})
-export class utExecuteComponent{
- dataSourceUnitTest: DataSource;
- currentSelectedUnitTest: UnitTest;
- Ergebnis: string;
- @ViewChild(DxDataGridComponent, { static: false }) dataGrid: DxDataGridComponent;
-
-
-
- constructor(
- private UnitTestService: UnitTestService,
- private layoutService: LayoutService,
- ) {
- this.dataSourceUnitTest = new DataSource({
- store: this.UnitTestService.getStore(),
-
- });
-
- }
-
-
- public executeUnitTest(){
- let UnitTestData: Structur[] = this.dataGrid.instance.getSelectedRowsData();
-
-
- //this.UnitTestService.executeUnitTest(UnitTestData[0]).subscribe(data => this.Ergebnis = data);
-
- if (UnitTestData.length == 0){
- return;
- }
-
- this.UnitTestService.executeUnitTest(UnitTestData[0]);
-
- //this.Ergebnis = this.UnitTestService.executeUnitTest(UnitTestData[0])
- }
- public LoadWorkspace(event){
- let UnitTestData: UnitTest[] = this.dataGrid.instance.getSelectedRowsData();
-
- this.UnitTestService.LoadWorkspace();
- notify("Workspaces werden geladen", "success", 6000);
- }
-
- public LoadDataset(event){
- let UnitTestData: UnitTest[] = this.dataGrid.instance.getSelectedRowsData();
-
- this.UnitTestService.LoadDataset();
- notify("Datasets werden geladen", "success", 6000);
- }
-
-}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.css b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.css
deleted file mode 100644
index c0ed655..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.css
+++ /dev/null
@@ -1,30 +0,0 @@
-::ng-deep #form-container {
- margin: 10px 10px 30px;
-}
-
-::ng-deep .long-title h3 {
- font-family: 'Segoe UI Light', 'Helvetica Neue Light', 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana;
- font-weight: 200;
- font-size: 28px;
- text-align: center;
- margin-bottom: 20px;
-}
-
-::ng-deep .dax-column{
- max-width: 200px;
-}
-
-::ng-deep .hide-checkbox .dx-select-checkbox{
- display: none;
-}
-
-::ng-deep .hide-checkbox .dx-treelist-icon-container{
- padding-right: 0px;
-}
-
-.popup-content {
- padding: 20px;
- text-align: center;
- }
-
-
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.html
deleted file mode 100644
index d01124d..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.html
+++ /dev/null
@@ -1,593 +0,0 @@
-Übersicht
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
UnitTests hinzufügen
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
UnitTests Bearbeiten
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
UserStory hinzufügen
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
UserStory bearbeiten
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Testläufe
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Wähle ein TabularModel aus in das kopiert werden soll:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.ts
deleted file mode 100644
index b2f4567..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.ts
+++ /dev/null
@@ -1,551 +0,0 @@
-import { Component, OnInit, ViewChild } from "@angular/core";
-import {LayoutParameter, LayoutService, NotificationType,} from "src/app/shared/services/layout.service";
-import notify from "devextreme/ui/notify";
-import { WorkspaceService } from "src/app/shared/services/workspace.service";
-import { Workspace } from "src/app/shared/models/workspace.model";
-import { UnitTestService } from "src/app/shared/services/UnitTest.service";
-import { UnitTest } from "src/app/shared/models/UnitTest.model";
-import { StructurService } from "src/app/shared/services/structur.service";
-import { Structur } from "src/app/shared/models/Structur.model";
-import { UserStoryService } from "src/app/shared/services/UserStory.service";
-import { UserStory } from "src/app/shared/models/UserStory.model";
-import { TabularModel } from "src/app/shared/models/TabularModel.model";
-import { DxTreeListComponent } from "devextreme-angular";
-import { TestRuns } from "src/app/shared/models/TestRuns.model";
-import { TestRunStructur } from "src/app/shared/models/TestRunStructur.model";
-import { TabularModelStructure } from "src/app/shared/models/TabularModelStructure";
-
-
-@Component({
- selector: "app-TreeViewTest",
- templateUrl: "./utTreeViewTest.component.html",
- styleUrls: ["./utTreeViewTest.component.css"],
- })
- export class utTreeViewTestComponent{
- public structures: Structur[];
- public TestRunsStructures: TestRunStructur[];
- public TabularModelStructures: TabularModelStructure[];
-
- public unitTestToEdit: UnitTest;
- public unitTestToDelete: UnitTest;
- public userStoryToEdit: UserStory;
- public userStoryToCopy: UserStory;
-
- public isPopupVisibleUTEdit: boolean = false;
- public isPopupVisibleUT: boolean = false;
- public isPopupVisibleUS: boolean = false;
- public isPopupVisibleTR: boolean = false;
- public isPopupVisibleTB: boolean = false;
- public isPopupVisibleUSedit: boolean = false;
- public isPopupVisibleDelete: boolean = false;
- public searchText: string = ''; // Property to hold the search text
-
-
- public ResultTypes: string[] = ["String", "Float","Date","Percentage"];
- public DateTimeFormats: string[] = ["UTC","CET"];
- public DateTimeFormats2: string[] = ["Long", "Short"];
- public Seperators: string[] = ["Use Seperators", "Dont use Sperators"];
- public decimal: string[]=["1","2","3","4","5"];
- public header: string = "Testläufe";
- public IsTypeString: boolean = false;
- public IsTypeDate: boolean = false;
- public IsTypeFloat: boolean = false;
-
- @ViewChild(DxTreeListComponent, { static: false }) treeList: DxTreeListComponent;
-
- constructor(
- private StructurService: StructurService,
- private WorkspaceService: WorkspaceService,
- private UnitTestService: UnitTestService,
- private UserStoryService: UserStoryService,
- private LayoutService: LayoutService)
- {
- this.loadData();
- // this.loadDataForPopUp();
- this.showUnitTestEdit = this.showUnitTestEdit.bind(this);
- this.showUserStoryEdit = this.showUserStoryEdit.bind(this);
- this.checkType = this.checkType.bind(this);
- this.deleteUnitTest = this.deleteUnitTest.bind(this);
- this.showUnitTest = this.showUnitTest.bind(this);
- this.showUserStory = this.showUserStory.bind(this);
- this.executeUnitTestsForRow = this.executeUnitTestsForRow.bind(this);
- this.editUserStory = this.editUserStory.bind(this);
- this.togglePopupDelete = this.togglePopupDelete.bind(this);
- this.showDelete = this.showDelete.bind(this);
- this.deleteWorkspace = this.deleteWorkspace.bind(this);
- this.loadDataForPopUp = this.loadDataForPopUp.bind(this);
- this.loadDataForPopUpTabModel = this.loadDataForPopUpTabModel.bind(this);
- this.showTestRuns = this.showTestRuns.bind(this);
- this.showTabModel = this.showTabModel.bind(this);
- this.showTestRunsLocal = this.showTestRunsLocal.bind(this);
- this.onClickCopyUserStory = this.onClickCopyUserStory.bind(this);
-
- }
-
- public loadData(): void {
- this.LayoutService.change(LayoutParameter.ShowLoading, true);
- this.WorkspaceService.getWorkspaces().then((Workspaces: Workspace[])=>{
- this.StructurService.getStructure(Workspaces).then((Structur) => {
- this.structures = Structur;
- this.LayoutService.change(LayoutParameter.ShowLoading, false);
- })
- });
- }
-
- public loadDataForPopUp(): void{
- this.StructurService.getRuns().then((TestRuns: TestRuns[]) => {
- this.StructurService.GetTestRunStructure(TestRuns).then((TRstructure) => {
- this.TestRunsStructures = TRstructure;
- })
- })
- }
-
- public loadDataForPopUpTabModel(): void{
- this.WorkspaceService.getWorkspaces().then((Workspaces: Workspace[]) => {
- this.StructurService.GetTabModelStructure(Workspaces).then((TBstructure) => {
- this.TabularModelStructures = TBstructure;
- })
- })
-
- }
-
- public onClickCopyUserStory(e: any): void{
-
-
- const userStoryId = this.userStoryToCopy.Id;
- const targetTabularModelId = e.row.data.Id;
- const targetWorkspaceId = e.row.data.Workspace;
-
- this.UserStoryService.copyToOtherTabularModel(userStoryId, targetTabularModelId, targetWorkspaceId)
- .then(() => {
- notify("UserStory wurde kopiert", "success", 2000);
- // Fügen Sie hier die gewünschten Aktualisierungen oder Benachrichtigungen hinzu
- })
- .catch((error) => {
- console.error("Fehler beim Kopieren der UserStory", error);
- // Hier können Sie Fehlerbehandlung oder Benachrichtigungen hinzufügen
- });
- this.isPopupVisibleTB = false;
- }
-
- public showTabModel(e: any)
- {
- this.loadDataForPopUpTabModel();
- this.userStoryToCopy = new UserStory();
- this.userStoryToCopy.Id = e.row.data.Id;
- this.isPopupVisibleTB = true;
-
- }
-
- public showTestRuns()
- {
- this.loadDataForPopUp();
-
- this.isPopupVisibleTR = true;
- }
-
- public showTestRunsLocal(e: any):void
- {
- this.header = "Testläufe von "+e.row.data.Typ + ": "+e.row.data.Name;
- this.StructurService.GetTestRunStructureForWorkspace(e.row.data.Name).then((TRstructure) => {
- this.TestRunsStructures = TRstructure;
- });
- this.isPopupVisibleTR = true;
- }
-
-
- public showUnitTestEdit(e: any): void{
- let unitTestStructure: Structur;
- if(e.row == undefined){
- if(e.data.Typ != "UnitTest") // disable double click for non-UnitTest rows
- return;
- unitTestStructure = e.data;
- }
- else
- unitTestStructure = e.row.data;
-
- let unitTest: UnitTest = {
- Id: unitTestStructure.Id,
- Name: unitTestStructure.Name,
- ExpectedResult: unitTestStructure.ExpectedResult,
- LastResult: unitTestStructure.LastResult,
- Timestamp: unitTestStructure.Timestamp,
- UserStory: unitTestStructure.UserStory,
- DAX: unitTestStructure.DAX
- };
- console.log("this.toggle", this);
- this.togglePopupUTEdit(unitTest);
-
- }
-
- public showUserStoryEdit(e: any): void
- {
- let userStory: UserStory = {
- Id: e.row.data.Id,
- Beschreibung: e.row.data.Name,
- TabularModel: e.row.node.parent.data.Id
- };
-
- this.togglePopupUSEdit(userStory);
- }
-
- public showUnitTest(e: any): void{
- let userStoryId: number = e.row.data.Id;
- this.togglePopupUT(userStoryId);
- }
-
- public showUserStory(e: any): void{
- let tabularModelId: number = e.row.data.Id;
- this.togglePopupUS(tabularModelId);
- }
-
- public showDelete(e: any)
- {
- let unitTestStructure: Structur;
- if(e.row == undefined){
- if(e.data.Typ != "UnitTest") // disable double click for non-UnitTest rows
- return;
- unitTestStructure = e.data;
- }
- else
- unitTestStructure = e.row.data;
-
-
- this.unitTestToDelete = {
- Id: unitTestStructure.Id,
- Name: unitTestStructure.Name,
- ExpectedResult: unitTestStructure.ExpectedResult,
- LastResult: unitTestStructure.LastResult,
- Timestamp: unitTestStructure.Timestamp,
- UserStory: unitTestStructure.UserStory,
- DAX: unitTestStructure.DAX
- };
- let unitTestX: UnitTest;
- unitTestX = this.unitTestToDelete;
- console.log("this.toggle", this);
- this.togglePopupDelete(unitTestX);
- }
-
- public onCellPrepared(e) {
- if(e.rowType === "data" && e.column.dataField === "LastResult") {
- e.cellElement.style.color = e.data.ExpectedResult == e.data.LastResult ? "green" : "red";
- }
- }
- public onRowPrepared(e: any): void{
- if (e.rowType == "data" && e.data.Typ != "UnitTest" || e.rowType == "header") {
- e.rowElement.classList.add("hide-checkbox");
- }
- }
-
- public addUserStory(e){
- this.UserStoryService.getStore().insert(this.userStoryToEdit).then(()=> {
- notify("UserStory '" + this.userStoryToEdit.Beschreibung + "' wurde hinzugefügt", "success", 2000);
- this.loadData();
- this.togglePopupUS();
- })
- }
-
- public addUnitTest(e){
- this.UnitTestService.getStore().insert(this.unitTestToEdit).then(()=> {
- notify("UnitTest '" + this.unitTestToEdit.Name + "' wurde hinzugefügt", "success", 2000);
- this.loadData();
- this.togglePopupUT();
- })
- }
-
- public editUnitTest(e){
- this.UnitTestService.getStore().update(this.unitTestToEdit.Id, this.unitTestToEdit).then(()=> {
- notify("UnitTest '" + this.unitTestToEdit.Name + "' wurde bearbeitet", "success", 2000);
- this.loadData();
- this.togglePopupUTEdit();
- })
- }
-
- public editUserStory(e){
- this.UserStoryService.getStore().update(this.userStoryToEdit.Id, this.userStoryToEdit).then(()=> {
- notify("UserStory '" + this.userStoryToEdit.Beschreibung + "' wurde bearbeitet", "success", 2000);
- this.loadData();
- this.togglePopupUSEdit();
- })
- }
-
- confirmDelete(answer: string, e: any): void {
- this.isPopupVisibleDelete = false; // Close the popup
- if (answer === 'yes') {
- this.deleteUnitTest(e);
- }
- }
-
- public deleteUnitTest(e: any){
- let id: number = e.Id;
- let name: string = e.Name;
-
- //this.isPopupVisibleDelete = true
-
-
- this.UnitTestService.getStore().remove(id).then(()=> {
- notify("UnitTest '" + name + "' wurde gelöscht", "success", 2000);
- this.loadData();
- });
- }
-
- public deleteWorkspace(e: any){
- let id: number = e.row.data.Id;
- let name: string = e.row.data.Name;
-
- this.WorkspaceService.getStore().remove(id).then(()=> {
- notify("Workspace '" + name + "' wurde gelöscht", "success", 2000);
- this.loadData();
- });
- }
-
- public deleteUnitTestsForSelection(e: any): void {
- this.LayoutService.change(LayoutParameter.ShowLoading, true);
- let results: void[] = new Array();
- let selectedRowsData: any[] = this.treeList.instance.getSelectedRowsData();
-
- if(selectedRowsData.length == 0)
- notify("No unit tests were selected", "error", 2000)
- else
- selectedRowsData.forEach(r =>
- { this.UnitTestService.getStore().remove(r.Id).then(()=> {
- notify("UnitTest '" + r.Name + "' wurde gelöscht", "success", 2000);
- this.loadData();
- });
- });
- }
-
- public LoadWorkspace(event){
- this.UnitTestService.LoadWorkspace();
- notify("Workspaces werden geladen", "success", 6000);
- }
-
- public executeUnitTestsForRow(e: any): void {
- this.LayoutService.change(LayoutParameter.ShowLoading, true);
- let rowData: Structur = e.row.data;
- delete (rowData as any).id;
- this.executeUnitTests(rowData).then((values) => {
- notify("All selected unit tests have been executed!", "success", 2000);
- this.LayoutService.change(LayoutParameter.ShowLoading, false);
- this.loadData();
- });
- }
-
- public isWorkspaceRow(e: any): boolean{
- if(e.row.rowType == "data" && e.row.data.Typ == "Workspace")
- return true;
- return false;
- }
-
- public isUnitTestRow(e: any): boolean{
- if(e.row.rowType == "data" && e.row.data.Typ == "UnitTest")
- return true;
- return false;
- }
-
- public isUserStoryRow(e: any): boolean{
- if(e.row.rowType == "data" && e.row.data.Typ == "UserStory")
- return true;
- return false;
- }
-
- public isTabularModelRow(e: any): boolean{
- if(e.row.rowType == "data" && e.row.data.Typ == "TabularModel")
- return true;
- return false;
- }
-
- public executeUnitTestsForSelection(e: any): void {
- this.LayoutService.change(LayoutParameter.ShowLoading, true);
- let results: Promise[] = new Array();
- let selectedRowsData: Structur[] = this.treeList.instance.getSelectedRowsData();
-
- if(selectedRowsData.length == 0)
- notify("No unit tests were selected", "error", 2000)
- else
- selectedRowsData.forEach(r =>
- {
- delete (r as any).id;
- results.push(this.executeUnitTests(r));
- });
-
- Promise.all(results).then((values) => {
- notify("All selected unit tests have been executed!", "success", 2000);
- this.LayoutService.change(LayoutParameter.ShowLoading, false);
- this.loadData();
- });
- }
-
- private togglePopupUT(userStoryId: number = undefined): void {
- this.isPopupVisibleUT = !this.isPopupVisibleUT;
- if(this.isPopupVisibleUT == true && userStoryId != undefined){
- this.unitTestToEdit = new UnitTest();
- this.unitTestToEdit.UserStory = userStoryId;
- }
- }
-
- private togglePopupUS(tabularModelId: number = undefined): void {
- this.isPopupVisibleUS = !this.isPopupVisibleUS;
- if(this.isPopupVisibleUS == true && tabularModelId != undefined){
- this.userStoryToEdit = new UserStory();
- this.userStoryToEdit.TabularModel = tabularModelId;
- }
- }
-
- private togglePopupUTEdit(unitTest: UnitTest = undefined): void {
- this.isPopupVisibleUTEdit = !this.isPopupVisibleUTEdit;
- if(this.isPopupVisibleUTEdit == true && unitTest != undefined){
- this.unitTestToEdit = unitTest;
- }
- }
-
- private togglePopupUSEdit(userStory: UserStory = undefined): void {
- this.isPopupVisibleUSedit = !this.isPopupVisibleUSedit;
- if(this.isPopupVisibleUSedit == true && userStory != undefined){
- this.userStoryToEdit = userStory;
- }
- }
-
- public togglePopupDelete(unitTest: UnitTest = undefined): void {
- this.isPopupVisibleDelete = !this.isPopupVisibleDelete;
- if(this.isPopupVisibleDelete == true && unitTest != undefined){
- this.unitTestToDelete = unitTest;
- }
- }
-
-
- public checkType(type: any){
- if(type.value == 'String')
- {
- this.IsTypeString = true;
- this.IsTypeFloat = false;
- this.IsTypeDate = false;
- }
-
- if(type.value == 'Float')
- {
- this.IsTypeFloat = true;
- this.IsTypeString = false;
- this.IsTypeDate = false;
- }
-
- if(type.value == 'Date')
- {
- this.IsTypeDate = true;
- this.IsTypeFloat = false;
- this.IsTypeString = false;
- }
- }
-
- private executeUnitTests(structur: Structur): Promise{
- let results: Promise[] = new Array();
-
- if(structur.Typ == "Workspace")
- results = this.executeUnitTestsOfWorkspace(this.structures.find(s => s.Id == structur.Id));
- else if(structur.Typ == "TabularModel")
- results = this.executeUnitTestsOfTabularModel(this.structures.find(s => s.WorkspacePbId == structur.WorkspacePbId).items.find(s => s.Typ == "TabularModel" && s.Id == structur.Id));
- else if (structur.Typ == "UserStory")
- results.push(this.executeUnitTestsOfUserStory(this.structures.find(s => s.WorkspacePbId == structur.WorkspacePbId).items.find(s => s.items.find(u => u.Id == structur.Id) != undefined).items.find(s => s.Typ == "UserStory" && s.Id == structur.Id)));
- else if (structur.Typ == "UnitTest")
- results.push(this.UnitTestService.executeUnitTest(structur));
-
- return Promise.all(results);
- }
-
- private executeUnitTestsOfUserStory(userstory: any): Promise{
- return new Promise((resolve)=> {
- let results: Promise[] = new Array();
- let Result : string;
- let Count : number;
- let i : number
- i = 0;
- Result = "True";
-
- userstory.items.forEach((unitTest: UnitTest) => {
- results.push(this.UnitTestService.executeUnitTest(unitTest as Structur).then(() =>
- {
- if(this.UnitTestService.wasUnitTestSuccessful == false)
- Result = "False"
- }));
- i++;
- Count = i;
-
- })
-
- Promise.all(results).then(() => {
- this.UnitTestService.SaveTestRun(Result, "UserStory", Count, userstory.Name);
-
- resolve();
- });
- })
- }
-
- private executeUnitTestsOfTabularModel(tabularModel: any): Promise[]{
- let results: Promise[] = new Array();
- let Result : string;
- let Count : number;
- let i : number
- i = 0;
- Result = "True";
-
- tabularModel.items.forEach((userStory: any) => {
- userStory.items.forEach((unitTest: UnitTest) =>
- {
- results = results.concat(this.UnitTestService.executeUnitTest(unitTest as Structur).then(() =>
- {
- if(this.UnitTestService.wasUnitTestSuccessful == false)
- Result = "False"
- }
-
- ));
- i++
- Count = i
-
- })
-
- })
-
- Promise.all(results).then(() => {
- this.UnitTestService.SaveTestRun(Result, "TabularModel" , Count, tabularModel.Name);
- });
-
- return results;
- }
-
- private executeUnitTestsOfWorkspace(workspace: any): Promise[]{
- let results: Promise[] = new Array();
- let Result : string;
- let Count : number;
- let i : number
- let Histories : History[];
- i = 0;
- Result = "True";
-
- workspace.items.forEach((tabularModel: any) => {
- tabularModel.items.forEach((userStory: any) => {
- userStory.items.forEach((unitTest: UnitTest) =>
- {
- results = results.concat(this.UnitTestService.executeUnitTest(unitTest as Structur).then(() =>
- {
- if(this.UnitTestService.wasUnitTestSuccessful == false)
- Result = "False"
-
- }
-
- ));
- i++
- Count = i
-
-
- })
-
- })
- })
-
- Promise.all(results).then(() => {
- this.UnitTestService.SaveTestRun(Result, "Workspace" , Count, workspace.Name);
- });
-
- return results;
- }
- }
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/History.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/History.model.ts
deleted file mode 100644
index 0d71fc4..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/History.model.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { TestRuns } from "./TestRuns.model";
-import { UnitTest } from "./UnitTest.model";
-
-export class History
-{
- public Id?: number;
- public TimeStamp?: string;
- public Result?: string;
- public LastRun?: string;
- public ExpectedRun: string;
- public UnitTest: number;
-
- public UnitTestNavigation?: UnitTest;
- public TestRunNavigation?: TestRuns;
-
-}
-
-
-
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/ResultType.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/ResultType.ts
deleted file mode 100644
index 379cff5..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/ResultType.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { UnitTest } from "./UnitTest.model";
-
-export class ResultType
-{
- Name?: string;
-
-
- UnitTests?: UnitTest[];
-}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/Structur.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/Structur.model.ts
deleted file mode 100644
index eea3ee6..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/Structur.model.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { UserStory } from "./UserStory.model";
-
-export class Structur {
- Typ?: string;
-
- Name?: string;
-
- WorkspacePbId?: string;
-
- DatasetPbId?: string;
-
- ExpectedResult?: string;
-
- DAX?: string;
-
- Timestamp?: string;
-
- LastResult?: string;
-
- Id?: number;
-
- UserStory?: number;
-
- UserStoryNavigation?: UserStory;
-
- items?: Structur[];
-}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModelStructure.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModelStructure.ts
deleted file mode 100644
index be44b96..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModelStructure.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { TestRunStructur } from "./TestRunStructur.model";
-import { UserStory } from "./UserStory.model";
-import { Workspace } from "./workspace.model";
-
-export interface TabularModelStructure {
- DatasetPbId?: string;
- Workspace?: number;
- Name?: string;
- Id?: number;
-
- items?: TestRunStructur[];
-
-}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRunStructur.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRunStructur.model.ts
deleted file mode 100644
index 895f5c1..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRunStructur.model.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { UserStory } from "./UserStory.model";
-
-export class TestRunStructur {
- public TimeStamp?: string;
- public Result?: string;
- public Workspace?: string;
- public TabularModel?: string;
- public UserStory?: string;
- public Count?: number;
- public Type?: string;
- public Name?: string;
-
- items?: TestRunStructur[];
-}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRuns.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRuns.model.ts
deleted file mode 100644
index 88af9fc..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRuns.model.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { UnitTest } from "./UnitTest.model";
-import { History } from "./History.model";
-
-export class TestRuns
-{
- public id?: number;
- public TimeStamp?: string;
- public Result?: string;
- public Workspace?: string;
- public TabularModel?: string;
- public UserStory?: string;
- public Count?: number;
- public Type?: string;
- public Name?: string;
-
- public HistoriesRun?: History[];
-
-
-}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTest.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTest.model.ts
deleted file mode 100644
index b3a2622..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTest.model.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { UserStory } from "./UserStory.model";
-import { History } from "./History.model";
-import { ResultType } from "./ResultType";
-
-export class UnitTest
-{
- public Id?: number;
-
- public Name?: string;
- public ExpectedResult?: string;
- public LastResult?: string;
- public Timestamp?: string;
- public UserStory?: number;
- public DAX?: string;
- public ResultType?: string;
- public DateTimeFormat?: string;
- public DecimalPlaces?: string;
- public FloatSeparators?: string;
-
- UserStoryNavigation?: UserStory;
- ResultTypeNavigation?: ResultType;
- Histories?: History[];
- }
-
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTestExecutionResult.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTestExecutionResult.ts
deleted file mode 100644
index 3f38732..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTestExecutionResult.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export interface UnitTestExecutionResult{
- unitTestSucceeded: boolean;
- unitTestExecuted: boolean;
-}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UserStory.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UserStory.model.ts
deleted file mode 100644
index db0b4aa..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UserStory.model.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { TabularModel } from "./TabularModel.model";
-import { UnitTest } from "./UnitTest.model";
-
-export class UserStory
-{
- Id?: number;
- Beschreibung?: string;
- TabularModel?: number;
-
- TabularModelNavigation?: TabularModel;
- UnitTests?: UnitTest[];
-}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/odatastringresponse.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/odatastringresponse.ts
deleted file mode 100644
index 8b06e6d..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/odatastringresponse.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export interface OdataStringResponse
-{
- value: string;
-}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModel.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/tabular-model.model.ts
similarity index 68%
rename from at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModel.model.ts
rename to at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/tabular-model.model.ts
index 47dd071..ee07070 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModel.model.ts
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/tabular-model.model.ts
@@ -1,12 +1,12 @@
-import { UserStory } from "./UserStory.model";
+import { UserStory } from "./user-story.model";
import { Workspace } from "./workspace.model";
export interface TabularModel {
Id?: number;
- DatasetPbId?: string;
+ UniqueIdentifier?: string;
+ MsId?: string;
Workspace?: number;
Name?: string;
-
- WorkspaceNavigation?: Workspace;
UserStories?: UserStory[];
+ WorkspaceNavigation?: Workspace;
}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run-collection.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run-collection.model.ts
new file mode 100644
index 0000000..08cf751
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run-collection.model.ts
@@ -0,0 +1,15 @@
+import { User } from "oidc-client";
+import { TestRun } from "./test-run.model";
+
+export interface TestRunCollection {
+ Id?: number;
+ TimeStamp?: string;
+ WasPassed?: boolean;
+ CreatedBy?: number | null;
+ CreatedOn?: string | null;
+ ModifiedBy?: number | null;
+ ModifiedOn?: string | null;
+ CreatedByNavigation?: User;
+ ModifiedByNavigation?: User;
+ TestRuns?: TestRun[];
+}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run.model.ts
new file mode 100644
index 0000000..91a4572
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run.model.ts
@@ -0,0 +1,23 @@
+import { User } from "oidc-client";
+import { UnitTest } from "./unit-test.model";
+import { TestRunCollection } from "./test-run-collection.model";
+
+export interface TestRun {
+ Id?: number;
+ TimeStamp?: string;
+ ExecutedSuccessfully?: boolean;
+ JsonResponse?: string;
+ WasPassed?: boolean;
+ Result?: string;
+ ExpectedResult?: string;
+ UnitTest?: number;
+ TestRunCollection?: number;
+ CreatedBy?: number | null;
+ CreatedOn?: string | null;
+ ModifiedBy?: number | null;
+ ModifiedOn?: string | null;
+ CreatedByNavigation?: User;
+ ModifiedByNavigation?: User;
+ UnitTestNavigation?: UnitTest;
+ TestRunCollectionNavigation?: TestRunCollection;
+}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/unit-test.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/unit-test.model.ts
new file mode 100644
index 0000000..9a108f3
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/unit-test.model.ts
@@ -0,0 +1,24 @@
+import { User } from "oidc-client";
+import { TestRun } from "./test-run.model";
+import { UserStory } from "./user-story.model";
+
+export interface UnitTest {
+ Id?: number;
+ UniqueIdentifier?: string;
+ Name?: string;
+ ExpectedResult?: string;
+ UserStory?: number;
+ DAX?: string;
+ ResultType?: string;
+ DateTimeFormat?: string;
+ DecimalPlaces?: string;
+ FloatSeparators?: string;
+ CreatedBy?: number | null;
+ CreatedOn?: string | null;
+ ModifiedBy?: number | null;
+ ModifiedOn?: string | null;
+ CreatedByNavigation?: User;
+ ModifiedByNavigation?: User;
+ TestRuns?: TestRun[];
+ UserStoryNavigation?: UserStory;
+}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/user-story.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/user-story.model.ts
new file mode 100644
index 0000000..bbb915b
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/user-story.model.ts
@@ -0,0 +1,18 @@
+import { User } from "oidc-client";
+import { UnitTest } from "./unit-test.model";
+import { TabularModel } from "./tabular-model.model";
+
+export interface UserStory {
+ Id?: number;
+ UniqueIdentifier?: string;
+ Name?: string;
+ TabularModel?: number;
+ CreatedBy?: number | null;
+ CreatedOn?: string | null;
+ ModifiedBy?: number | null;
+ ModifiedOn?: string | null;
+ CreatedByNavigation?: User;
+ ModifiedByNavigation?: User;
+ UnitTests?: UnitTest[];
+ TabularModelNavigation?: TabularModel;
+}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/workspace.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/workspace.model.ts
index fac3f7c..63bddfe 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/workspace.model.ts
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/workspace.model.ts
@@ -1,11 +1,12 @@
-import { TabularModel } from "./TabularModel.model";
+import { TabularModel } from "./tabular-model.model";
+import { Tenant } from "./tenant.model";
-export interface Workspace{
-
- Name?: string;
+export interface Workspace {
Id?: number;
- WorkspacePbId?: string;
-
+ Name?: string;
+ MsId?: string;
+ UniqueIdentifier?: string;
+ Tenant?: number | null;
+ TenantNavigation?: Tenant;
TabularModels?: TabularModel[];
-
}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/pipes/get-first-element.pipe.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/pipes/get-first-element.pipe.ts
new file mode 100644
index 0000000..9ca706e
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/pipes/get-first-element.pipe.ts
@@ -0,0 +1,13 @@
+import { Pipe, PipeTransform } from '@angular/core';
+import { LogService } from '../services/log.service';
+
+@Pipe({
+ name: 'getFirstElement'
+})
+export class GetFirstElementPipe implements PipeTransform {
+ constructor(private logService: LogService) {}
+
+ transform(array: any[]): any {
+ return array?.length > 0 ? array[0] : null;
+ }
+}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UnitTest.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UnitTest.service.ts
deleted file mode 100644
index 683a6bb..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UnitTest.service.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-import { HttpClient } from "@angular/common/http";
-import { Injectable } from "@angular/core";
-import ODataStore from "devextreme/data/odata/store";
-import { AppConfig } from "../config/app.config";
-import { ODataService } from "./odata.service";
-import { UserService } from "./user.service";
-import { LayoutService } from "./layout.service";
-import { UnitTest } from "src/app/shared/models/UnitTest.model";
-import ODataContext from "devextreme/data/odata/context";
-import { map } from "rxjs/operators";
-import { Structur } from "../models/Structur.model";
-import {OdataStringResponse} from "../models/odatastringresponse";
-import notify from "devextreme/ui/notify";
-import { UnitTestExecutionResult } from "../models/UnitTestExecutionResult";
-
-@Injectable()
-export class UnitTestService {
- respons: boolean;
- wasUnitTestSuccessful: boolean = false;
- constructor(
- private odataService: ODataService,
- //private UnitTestService: UnitTestService,
- private http: HttpClient,
-
-
- ) { }
-
- getStore(): ODataStore {
- return this.odataService.context["UnitTests"];
- }
- //executeUnitTest(unitTestToExecute: UnitTest) {
-
- //var urlToCall = AppConfig.settings.api.url + "/UnitTests/Execute";
-
- // this.http.post(urlToCall, unitTestToExecute)
- // .subscribe(
- // result => {
- // console.log(result);
- //},error => {console.log(error)}
- //)
-
- //}
-
-// Structur / UnitTest
- executeUnitTest(unitTestToExecute: Structur): Promise{
- return new Promise((resolve)=> {
-
- let request = this.http
- .post(`${AppConfig.settings.api.url}/UnitTests/Execute`, unitTestToExecute)
- .subscribe(
- response => {
-
- resolve();
- if(response.unitTestExecuted == true){
-
- if(response.unitTestSucceeded == true){
- /* e.rowElement.style.backgroundcolor = "green";*/
- //notify("UnitTest: " + unitTestToExecute.Name + " war erfolgreich!" + " Erwartetes Ergebnis: " + unitTestToExecute.ExpectedResult + " Letztes Ergebnis: " + unitTestToExecute.LastResult, "success", 6000);
- this.wasUnitTestSuccessful = true;
- }
- else{
- /*e.rowElement.style.backgroundcolor = "red";
- return response.unitTestSucceeded*/
- //notify("UnitTest: " + unitTestToExecute.Name + " nicht bestanden!" + " Erwartetes Ergebnis: " + unitTestToExecute.ExpectedResult + " Letztes Ergebnis: " + unitTestToExecute.LastResult, "info", 6000);
- }
- }
- else{
- notify("UnitTest: " + unitTestToExecute.Name + " konnte nicht ausgeführt werden", "error", 3000);
- }
-
- },
- error => {
- notify(error.message, "error", 3000);
- }
-
- );
-
- });
-
- //return this.odataService.context["UnitTests/Execute"];
- }
-
- LoadWorkspace(){
- let request = this.http
- .post(`${AppConfig.settings.api.url}/UnitTests/LoadWorkspace`, null)
- .subscribe(() => {console.log("OK")});
- }
-
- LoadDataset(){
- let request = this.http
- .post(`${AppConfig.settings.api.url}/UnitTests/LoadDataset`, null)
- .subscribe(() => {console.log("OK")});
- }
-
- SaveTestRun(result : string, type : string, count : number, Name : String){
- let body = {
- result : result,
- type : type,
- count : count
- }
-
- let request = this.http
- .post(`${AppConfig.settings.api.url}/UnitTests/SaveTestRun`, {
- Result : result, Type : type, Count : count, Name: Name,
- })
- .subscribe(() => {console.log("OK")});
- }
-
-
-}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/crud-base.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/crud-base.service.ts
new file mode 100644
index 0000000..1901b3f
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/crud-base.service.ts
@@ -0,0 +1,20 @@
+import { HttpClient } from "@angular/common/http";
+import ODataStore from "devextreme/data/odata/store";
+import { ODataService } from "./odata.service";
+
+
+export abstract class CrudBaseService {
+ abstract getStore(): ODataStore;
+
+ public add (newRecord: Model): Promise {
+ return this.getStore().insert(newRecord);
+ }
+
+ public remove (id: number): Promise {
+ return this.getStore().remove(id);
+ }
+
+ public update (id: number, changes: Model): Promise {
+ return this.getStore().update(id, changes);
+ }
+}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/history.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/history.service.ts
deleted file mode 100644
index fff6b3b..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/history.service.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { HttpClient } from "@angular/common/http";
-import { Injectable } from "@angular/core";
-import ODataStore from "devextreme/data/odata/store";
-import { AppConfig } from "../config/app.config";
-import { ODataService } from "./odata.service";
-import { UserService } from "./user.service";
-import { LayoutService } from "./layout.service";
-import { UnitTest } from "src/app/shared/models/UnitTest.model";
-import ODataContext from "devextreme/data/odata/context";
-import { map } from "rxjs/operators";
-import { History } from "../models/History.model";
-@Injectable()
-export class HistoryService {
-
- constructor(
- private odataService: ODataService,
- //private UserStoryService: UserStoryService,
- private http: HttpClient,
-
- ) { }
-
- getStore(): ODataStore {
- return this.odataService.context["History"];
- }
-
-}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/odata.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/odata.service.ts
index 4aed051..46ed04e 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/odata.service.ts
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/odata.service.ts
@@ -10,7 +10,6 @@ export class ODataService {
context: ODataContext;
constructor(private router: Router, private logService: LogService) {
this.context = new ODataContext({
- beforeSend: (e) => {},
url: AppConfig.settings.api.url,
version: 4,
errorHandler: (error) => {
@@ -44,7 +43,10 @@ export class ODataService {
key: "Id",
keyType: "Int32",
},
-
+ ResultTypes: {
+ key: "Id",
+ keyType: "Int32",
+ }
},
});
}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/structur.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/structur.service.ts
deleted file mode 100644
index 0dc64c1..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/structur.service.ts
+++ /dev/null
@@ -1,319 +0,0 @@
-import { Injectable } from '@angular/core';
-import { Test } from 'tslint';
-import { Structur } from '../models/Structur.model';
-import { UnitTest } from '../models/UnitTest.model';
-import { Workspace } from '../models/workspace.model';
-import ODataContext from "devextreme/data/odata/context";
-import { AppConfig } from '../config/app.config';
-import { HttpClient } from "@angular/common/http";
-import { ODataService } from './odata.service';
-import { TestRuns } from '../models/TestRuns.model';
-import { TestRunStructur } from '../models/TestRunStructur.model';
-import { TabularModelService } from './TabularModel.service';
-import { History } from '../models/History.model';
-import { UnitTestService } from './UnitTest.service';
-import HierarchicalCollectionWidget from 'devextreme/ui/hierarchical_collection/ui.hierarchical_collection_widget';
-import { TabularModel } from '../models/TabularModel.model';
-import { TabularModelStructure } from '../models/TabularModelStructure';
-var structures: Structur[];
-
-@Injectable()
-export class StructurService {
-
- constructor(
- private odataService: ODataService,
- //private UserStoryService: UserStoryService,
- private http: HttpClient,
- private UnitTestService: UnitTestService,
-
-
- ) { }
-
-
- LoadWorkspace() {
- let request = this.http
- .post(`${AppConfig.settings.api.url}/UnitTests/LW`, null)
- .subscribe(() => { console.log("OK") });
-
- }
-
- getWorkspaces2(): Promise {
- return new Promise((resolve, reject) => {
- let request = this.http
- .post(`${AppConfig.settings.api.url}/Workspaces/FilterWorkspace`, null)
- .subscribe(
- response => {
- resolve(response["value"]);
- }
- );
-
- });
-
- }
-
- getRuns(): Promise {
- return new Promise((resolve, reject) => {
- let request = this.http
- .get(`${AppConfig.settings.api.url}/TestRuns?$expand=HistoriesRun($expand=UnitTestNavigation)`)
- .subscribe(
- response => {
- resolve(response["value"]);
- }
- );
-
- });
-
- }
-
- getTabModels(): Promise {
- return new Promise((resolve, reject) => {
- let request = this.http
- .get(`${AppConfig.settings.api.url}/TabularModels`)
- .subscribe(
- response => {
- resolve(response["value"]);
- }
- );
-
- });
-
- }
-
-
- GetTabModelStructure(Workspaces: Workspace[]): Promise{
- return new Promise((resolve, reject) => {
- var TBstructures: TabularModelStructure[] = [];
-
-
- this.getWorkspaces2().then((filter) => {
- Workspaces.forEach(Workspace => {
- if (filter.some(p => p.WorkspacePbId === Workspace.WorkspacePbId.valueOf())) {
-
-
-
- Workspace.TabularModels.forEach(TabularModel => {
- var structureTabularModel: TabularModelStructure = {
- Name: TabularModel.Name,
- DatasetPbId: TabularModel.DatasetPbId,
- Workspace: TabularModel.Workspace,
- Id: TabularModel.Id,
-
- items: [],
-
-
- };
- TBstructures.push(structureTabularModel);
- })
-
-
-
-
- }
-
- });
- resolve(TBstructures);
- });
-
-
- });
- }
-
-
-
- getStructure(Workspaces: Workspace[]): Promise {
- return new Promise((resolve, reject) => {
- var structures: Structur[] = [];
-
- this.getWorkspaces2().then((filter) => {
- Workspaces.forEach(Workspace => {
- if (filter.some(p => p.WorkspacePbId === Workspace.WorkspacePbId.valueOf())) {
-
- var structureWorkspace: Structur = {
- Typ: "Workspace",
- Name: Workspace.Name,
- WorkspacePbId: Workspace.WorkspacePbId,
- DatasetPbId: null,
- ExpectedResult: "",
- DAX: "",
- Timestamp: null,
- LastResult: "",
- Id: Workspace.Id,
- UserStory: null,
- UserStoryNavigation: null,
- items: []
- };
-
- Workspace.TabularModels.forEach(TabularModel => {
- var structureTabularModel: Structur = {
- Typ: "TabularModel",
- Name: TabularModel.Name,
- WorkspacePbId: Workspace.WorkspacePbId,
- DatasetPbId: TabularModel.DatasetPbId,
- ExpectedResult: "",
- DAX: "",
- Timestamp: null,
- LastResult: "",
- Id: TabularModel.Id,
- UserStory: null,
- UserStoryNavigation: null,
- items: []
- };
-
- TabularModel.UserStories.forEach(UserStory => {
- var structureUserStory: Structur = {
- Typ: "UserStory",
- Name: UserStory.Beschreibung,
- WorkspacePbId: Workspace.WorkspacePbId,
- DatasetPbId: TabularModel.DatasetPbId,
- ExpectedResult: "",
- DAX: "",
- Timestamp: null,
- LastResult: "",
- Id: UserStory.Id,
- UserStory: null,
- UserStoryNavigation: null,
- items: []
- };
-
- UserStory.UnitTests.forEach(UnitTest => {
- var structureUnitTest: Structur = {
- Typ: "UnitTest",
- Name: UnitTest.Name,
- WorkspacePbId: Workspace.WorkspacePbId,
- DatasetPbId: TabularModel.DatasetPbId,
- ExpectedResult: UnitTest.ExpectedResult,
- DAX: UnitTest.DAX,
- Timestamp: UnitTest.Timestamp,
- LastResult: UnitTest.LastResult,
- Id: UnitTest.Id,
- UserStory: UnitTest.UserStory,
- UserStoryNavigation: UnitTest.UserStoryNavigation,
- items: []
- };
- structureUserStory.items.push(structureUnitTest)
- })
- structureTabularModel.items.push(structureUserStory)
- })
- structureWorkspace.items.push(structureTabularModel);
- })
- structures.push(structureWorkspace);
- }
- });
- resolve(structures);
- });
- });
- }
-
- GetTestRunStructure(TestRuns: TestRuns[]): Promise{
- return new Promise((resolve, reject) => {
- var TRstructures: TestRunStructur[] = [];
- var TRname;
- var HistoryName
- var HistoryKey
-
- this.getRuns().then(() => {
- TestRuns.forEach(TestRun => {
-
- if(TestRun.Workspace != null)
- TRname = TestRun.Workspace;
-
- if(TestRun.TabularModel != null)
- TRname = TestRun.TabularModel;
-
- if(TestRun.UserStory != null)
- TRname = TestRun.UserStory;
-
- var structureTestRuns: TestRunStructur = {
- Type: TestRun.Type,
- TimeStamp: TestRun.TimeStamp,
- Result: TestRun.Result,
- Workspace: TestRun.Workspace,
- TabularModel: TestRun.TabularModel,
- UserStory: TestRun.UserStory,
- Name: TRname,
- items: [],
-
-
- };
-
- TestRun.HistoriesRun.forEach(History => {
-
- //HistoryKey = this.UnitTestService.getStore().keyOf(History['UnitTest'])
-
- /*this.UnitTestService.getStore().byKey(History.UnitTest).then((unitTest) => {
- HistoryName = unitTest.Name;
- })*/
- //HistoryName = History.UnitTest.Name;
-
- var StructureHitory: TestRunStructur ={
- TimeStamp: History.TimeStamp,
- Result: History.Result,
- Name: History.UnitTestNavigation.Name,
- Type: "/",
- items: [],
- Workspace: "",
- TabularModel: "",
- UserStory:""
- }
- structureTestRuns.items.push(StructureHitory)
- })
- TRstructures.push(structureTestRuns);
-
- });
- resolve(TRstructures);
- });
-
-
- });
- }
-
- GetTestRunStructureForWorkspace(workspaceName: string): Promise {
- return new Promise((resolve, reject) => {
- var TRstructures: TestRunStructur[] = [];
- var TRname;
- var HistoryName;
- var HistoryKey;
-
- this.getRuns().then((TestRuns) => {
- const filteredTestRuns = TestRuns.filter((TestRun) => {
- // Hier kannst du die Bedingung anpassen, um nach einem bestimmten Workspace zu filtern.
- return TestRun.Workspace === workspaceName || TestRun.TabularModel === workspaceName || TestRun.UserStory === workspaceName;
- });
-
- filteredTestRuns.forEach((TestRun) => {
- if (TestRun.Workspace != null) TRname = TestRun.Workspace;
- if (TestRun.TabularModel != null) TRname = TestRun.TabularModel;
- if (TestRun.UserStory != null) TRname = TestRun.UserStory;
-
- var structureTestRuns: TestRunStructur = {
- Type: TestRun.Type,
- TimeStamp: TestRun.TimeStamp,
- Result: TestRun.Result,
- Workspace: TestRun.Workspace,
- TabularModel: TestRun.TabularModel,
- UserStory: TestRun.UserStory,
- Name: TRname,
- items: [],
- };
-
- TestRun.HistoriesRun.forEach((History) => {
- var StructureHistory: TestRunStructur = {
- TimeStamp: History.TimeStamp,
- Result: History.Result,
- Name: History.UnitTestNavigation.Name,
- Type: "/",
- items: [],
- Workspace: "",
- TabularModel: "",
- UserStory: "",
- };
- structureTestRuns.items.push(StructureHistory);
- });
- TRstructures.push(structureTestRuns);
- });
- resolve(TRstructures);
- });
- });
-}
-
-}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/TabularModel.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/tabular-model.service.ts
similarity index 99%
rename from at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/TabularModel.service.ts
rename to at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/tabular-model.service.ts
index 806ff03..0a7e6fe 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/TabularModel.service.ts
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/tabular-model.service.ts
@@ -15,5 +15,4 @@ export class TabularModelService {
getStore(): ODataStore {
return this.odataService.context["TabularModels"];
}
-
}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/unit-test.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/unit-test.service.ts
new file mode 100644
index 0000000..576e734
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/unit-test.service.ts
@@ -0,0 +1,37 @@
+import { HttpClient } from "@angular/common/http";
+import { Injectable } from "@angular/core";
+import ODataStore from "devextreme/data/odata/store";
+import { AppConfig } from "../config/app.config";
+import { ODataService } from "./odata.service";
+import { UserService } from "./user.service";
+import { LayoutService } from "./layout.service";
+import { UnitTest } from "src/app/shared/models/unit-test.model";
+import { CrudBaseService } from "src/app/shared/services/crud-base.service";
+import ODataContext from "devextreme/data/odata/context";
+import { map } from "rxjs/operators";
+import notify from "devextreme/ui/notify";
+
+@Injectable()
+export class UnitTestService extends CrudBaseService {
+ constructor(
+ private odataService: ODataService,
+ private http: HttpClient
+ ) {
+ super();
+ }
+
+ getStore(): ODataStore {
+ return this.odataService.context["UnitTests"];
+ }
+
+ public executeMultiple(ids: number[]): Promise {
+ return new Promise((resolve, reject) => {
+ let request = this.http
+ .post(`${AppConfig.settings.api.url}/UnitTests/Execute`, { unitTestIds: ids })
+ .subscribe({
+ next: () => resolve(),
+ error: (error: any) => reject(error?.error?.error)
+ });
+ });
+ }
+}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UserStory.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/user-story.service.ts
similarity index 63%
rename from at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UserStory.service.ts
rename to at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/user-story.service.ts
index 4978009..ee00c32 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UserStory.service.ts
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/user-story.service.ts
@@ -5,36 +5,34 @@ import { AppConfig } from "../config/app.config";
import { ODataService } from "./odata.service";
import { UserService } from "./user.service";
import { LayoutService } from "./layout.service";
-import { UnitTest } from "src/app/shared/models/UnitTest.model";
+import { UnitTest } from "src/app/shared/models/unit-test.model";
import ODataContext from "devextreme/data/odata/context";
import { map } from "rxjs/operators";
-import { UserStory } from "../models/UserStory.model";
+import { UserStory } from "../models/user-story.model";
+import { CrudBaseService } from "./crud-base.service";
@Injectable()
-export class UserStoryService {
+export class UserStoryService extends CrudBaseService{
constructor(
private odataService: ODataService,
- //private UserStoryService: UserStoryService,
private http: HttpClient,
+ ) {
+ super();
+ }
- ) { }
-
- getStore(): ODataStore {
+ public getStore(): ODataStore {
return this.odataService.context["UserStories"];
}
- public copyToOtherTabularModel(userStoryId: number, targetTabularModelId: number, targetWorkspaceId: number): Promise {
+ public copyToOtherTabularModel(userStoryId: number, targetTabularModelId: number): Promise {
return new Promise((resolve, reject) => {
let request = this.http
- .post(`${AppConfig.settings.api.url}/UserStories(${userStoryId})/Copy2`, {
- targetTabularModelId1: targetTabularModelId,
- targetWorkspaceId1: targetWorkspaceId,
- userStoryId1: userStoryId,
-
+ .post(`${AppConfig.settings.api.url}/UserStories(${userStoryId})/Copy`, {
+ targetTabularModelId: targetTabularModelId
})
.subscribe({
next: (data) => resolve(),
- error: (error) => reject(error),
+ error: (error) => reject(error?.error?.error),
});
});
}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/workspace.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/workspace.service.ts
index f3f6995..412f335 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/workspace.service.ts
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/workspace.service.ts
@@ -8,58 +8,27 @@ import { LayoutService } from "./layout.service";
import ODataContext from "devextreme/data/odata/context";
import { map } from "rxjs/operators";
import { Workspace } from "../models/workspace.model";
-import { UserStoryService } from "./UserStory.service";
+import { UserStoryService } from "./user-story.service";
@Injectable()
export class WorkspaceService {
-
constructor(
private odataService: ODataService,
private userStoryService: UserStoryService,
- private http: HttpClient,
-
- ) { }
-
- getStore(): ODataStore {
- return this.odataService.context["Workspaces"]
- }
- getStore2(){
- let request = this.http
- .post(`${AppConfig.settings.api.url}/Workspaces/FilterWorkspace`, null)
- .subscribe(
- response => {
- return response;
- },
- );
- }
+ private http: HttpClient
+ ) {}
- getStore3(): ODataStore {
- return this.odataService.context["Workspaces/FilterWorkspace"]
+ public getStore(): ODataStore {
+ return this.odataService.context["Workspaces"];
}
- getWorkspaces(): Promise {
- return new Promise((resolve, reject)=>{
- this.getStore().load({expand: ["TabularModels.UserStories.UnitTests"]}).then((data)=>{
- resolve(data as Workspace[]);
- }).catch((error)=>{
- reject(error);
- })
- });
-
- }
-
- getWorkspaces2(): Promise {
- return new Promise((resolve, reject)=>{
+ public pullWorkspaces(): Promise {
+ return new Promise((resolve, reject) => {
let request = this.http
- .post(`${AppConfig.settings.api.url}/Workspaces/FilterWorkspace`, null)
- .subscribe(
- response => {
- resolve(response["value"]);
- },
- );
+ .post(`${AppConfig.settings.api.url}/Workspaces/Pull`, {})
+ .subscribe({
+ next: () => resolve(),
+ error: () => reject ()
+ });
});
-
}
-
-
-
}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/index.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/index.html
index 17c6baa..08d65a3 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/index.html
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/index.html
@@ -2,7 +2,7 @@
- Power BI Uni Test Portal - applied technologies GmbH
+ Power BI Unit Test Portal - applied technologies GmbH
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/BaseController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/BaseController.cs
index 8ca5684..8268582 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/BaseController.cs
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/BaseController.cs
@@ -18,14 +18,15 @@ public abstract class BaseController : ODataController
protected Guid msIdTenantCurrentUser;
protected Guid msIdCurrentUser;
- protected IHttpContextAccessor HttpContextAccessor;
+ protected IHttpContextAccessor httpContextAccessor;
- public BaseController(PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor)
+ public BaseController(PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, ILogger logger)
{
dbContext = portalDbContext;
this.downstreamWebApi = downstreamWebApi;
- this.HttpContextAccessor = httpContextAccessor;
+ this.httpContextAccessor = httpContextAccessor;
+ this.logger = logger;
this.msIdTenantCurrentUser = Guid.Parse(httpContextAccessor.HttpContext.User.FindFirst(ClaimConstants.TenantId).Value);
this.msIdCurrentUser = Guid.Parse(httpContextAccessor.HttpContext.User.FindFirst(ClaimConstants.ObjectId).Value);
this.dbContext.MsIdCurrentUser = this.msIdCurrentUser;
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/HistoriesController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/HistoriesController.cs
deleted file mode 100644
index 1883b4e..0000000
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/HistoriesController.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using at.PowerBIUnitTest.Portal.Data.Models;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.OData;
-using Microsoft.AspNetCore.OData.Query;
-using Microsoft.AspNetCore.OData.Extensions;
-using Microsoft.Identity.Web;
-using System.Linq;
-using Microsoft.Extensions.Logging;
-using System;
-using Microsoft.AspNetCore.OData.Routing;
-using System.Threading.Tasks;
-using Microsoft.Extensions.Configuration;
-using Microsoft.AspNetCore.OData.Formatter;
-using Microsoft.AspNet.OData.Routing;
-using Newtonsoft.Json;
-
-namespace at.PowerBIUnitTest.Portal.Controllers
-{
-
- public class HistoriesController : BaseController
-
- {
- private readonly IConfiguration configuration;
- private readonly ILogger logger;
-
- public HistoriesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor)
- {
- this.configuration = configuration;
- this.logger = logger;
- }
- [EnableQuery]
- public IQueryable Get()
- {
- logger.LogDebug($"Begin & End: HistoriesController Get()");
- return base.dbContext.Histories;
- }
- }
-
-}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TabularModelsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TabularModelsController.cs
index ca7fb53..260bd1f 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TabularModelsController.cs
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TabularModelsController.cs
@@ -19,35 +19,24 @@
namespace at.PowerBIUnitTest.Portal.Controllers
{
-
public class TabularModelsController : BaseController
{
- private readonly IConfiguration configuration;
- private readonly ILogger logger;
- public TabularModelsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor)
+ public TabularModelsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger)
{
- this.configuration = configuration;
- this.logger = logger;
}
-
- [EnableQuery(MaxExpansionDepth = 4)]
- [AllowAnonymous]
- public IQueryable Get()
+ [EnableQuery]
+ public IQueryable Get([FromODataUri] int key)
{
- try
- {
- logger.LogDebug($"Begin & End: TabularModelsController Get()");
- return base.dbContext.TabularModels;
- }
- catch(Exception ex)
- {
- logger.LogError(ex, "An error occured while performig GET(TabModel)");
- throw;
- }
- }
+ logger.LogDebug($"Begin & End: TabularModelsController Get(key: {key})");
+ return base.dbContext.TabularModels.Where(e => e.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key);
+ }
+ [EnableQuery]
+ public IQueryable Get()
+ {
+ logger.LogDebug($"Begin & End: TabularModelsController Get()");
+ return base.dbContext.TabularModels.Where(e => e.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser);
+ }
}
-
-
}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TenantsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TenantsController.cs
index 790877b..84bb495 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TenantsController.cs
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TenantsController.cs
@@ -1,24 +1,27 @@
using at.PowerBIUnitTest.Portal.Data.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.OData.Query;
using Microsoft.Identity.Web;
using System.Linq;
using Microsoft.Extensions.Logging;
using at.PowerBIUnitTest.Portal.Services;
+using Microsoft.AspNet.OData;
namespace at.PowerBIUnitTest.Portal.Controllers
{
- [Authorize]
public class TenantsController : BaseController
{
- private readonly ILogger logger;
- public TenantsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor)
+ public TenantsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger)
{
- this.logger = logger;
}
- // GET: odata/Tenants
+ [EnableQuery]
+ public IQueryable Get([FromODataUri] int key)
+ {
+ logger.LogDebug($"Begin & End: TenantsController Get(key: {key})");
+ return base.dbContext.Tenants.Where(e => e.MsId == this.msIdTenantCurrentUser && e.Id == key);
+ }
+
[EnableQuery]
public IQueryable Get()
{
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunCollectionsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunCollectionsController.cs
new file mode 100644
index 0000000..7a34874
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunCollectionsController.cs
@@ -0,0 +1,31 @@
+using System.Linq;
+using at.PowerBIUnitTest.Portal.Data.Models;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+using Microsoft.Identity.Web;
+
+namespace at.PowerBIUnitTest.Portal.Controllers
+{
+ public class TestRunCollectionsController : BaseController
+ {
+ public TestRunCollectionsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger)
+ {
+ }
+
+ [EnableQuery]
+ public IQueryable Get([FromODataUri] int key)
+ {
+ logger.LogDebug($"Begin & End: TestRunCollectionsController Get(key: {key})");
+ return base.dbContext.TestRunCollections.Where(e => e.TestRuns.Count > 0 && e.TestRuns.First().UnitTestNavigation.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key);
+ }
+
+ [EnableQuery]
+ public IQueryable Get()
+ {
+ logger.LogDebug($"Begin & End: TestRunCollectionsController Get()");
+ return base.dbContext.TestRunCollections.Where(e => e.TestRuns.Count > 0 && e.TestRuns.First().UnitTestNavigation.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser);
+ }
+ }
+}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunsController.cs
index a0afd5b..a1634a7 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunsController.cs
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunsController.cs
@@ -1,29 +1,31 @@
-using at.PowerBIUnitTest.Portal.Data.Models;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.OData.Query;
-using Microsoft.Identity.Web;
using System.Linq;
+using at.PowerBIUnitTest.Portal.Data.Models;
+using Microsoft.AspNet.OData;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
-using at.PowerBIUnitTest.Portal.Services;
+using Microsoft.Identity.Web;
namespace at.PowerBIUnitTest.Portal.Controllers
{
public class TestRunsController : BaseController
{
- private readonly ILogger logger;
- public TestRunsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor)
+ public TestRunsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger)
+ {
+ }
+
+ [EnableQuery]
+ public IQueryable Get([FromODataUri] int key)
{
- this.logger = logger;
+ logger.LogDebug($"Begin & End: TestRunsController Get(key: {key})");
+ return base.dbContext.TestRuns.Where(e => e.UnitTestNavigation.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key);
}
- // GET: odata/TestRuns
[EnableQuery]
- [AllowAnonymous]
- public IQueryable Get()
+ public IQueryable Get()
{
- logger.LogDebug($"Begin & End: TestRunssController Get()");
- return base.dbContext.TestRuns;
+ logger.LogDebug($"Begin & End: TestRunsController Get()");
+ return base.dbContext.TestRuns.Where(e => e.UnitTestNavigation.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser);
}
}
-}
+}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UnitTestsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UnitTestsController.cs
index 149ce93..12a39e3 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UnitTestsController.cs
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UnitTestsController.cs
@@ -15,11 +15,13 @@
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNet.OData.Routing;
using Newtonsoft.Json;
-using at.PowerBIUnitTest.Portal.Services;
using Microsoft.AspNetCore.OData.Deltas;
using Microsoft.AspNetCore.Routing;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.OData;
+using at.PowerBIUnitTest.Portal.Services;
namespace at.PowerBIUnitTest.Portal.Controllers
{
@@ -27,514 +29,111 @@ namespace at.PowerBIUnitTest.Portal.Controllers
[Authorize]
public class UnitTestsController : BaseController
{
- private readonly IConfiguration configuration;
- private IHttpContextAccessor _httpContextAccessor;
- private readonly ILogger logger;
- private static List HistoriesForTestRun = new List();
- public UnitTestsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor)
+ public UnitTestsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger)
{
- this.configuration = configuration;
- _httpContextAccessor = httpContextAccessor;
- this.logger = logger;
+
}
- // GET: odata/UnitTests
- [EnableQuery]
- public IQueryable Get()
+ [EnableQuery(MaxExpansionDepth = 4)]
+ public IQueryable Get([FromODataUri] int key)
{
- try
- {
- logger.LogDebug($"Begin & End: UnitTestsController Get()");
- return base.dbContext.UnitTests;
- }
- catch (Exception ex)
- {
- logger.LogError(ex, "An error occured while performing GET");
- throw;
- }
+ logger.LogDebug($"Begin & End: UnitTestsController Get(key: {key})");
+ return base.dbContext.UnitTests.Where(e => e.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key);
}
- // Add odata/UnitTests
- [HttpPost]
- public UnitTest Post([FromBody] UnitTest unitTest)
+ [EnableQuery(MaxExpansionDepth = 4)]
+ public IQueryable Get()
{
- try
- {
- logger.LogDebug($"Begin & End: UnitTestsController Post()");
- var newUnitTest = base.dbContext.Add(unitTest);
- base.dbContext.SaveChanges();
-
- return newUnitTest.Entity;
- }
- catch (Exception ex)
- {
- logger.LogError(ex, "An error occured while performing POST");
- throw;
-
- }
+ logger.LogDebug($"Begin & End: UnitTestsController Get()");
+ return base.dbContext.UnitTests.Where(e => e.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser);
}
- [AllowAnonymous]
[HttpPost]
- public async Task SaveTestRun(ODataActionParameters parmeters)
+ public async Task Post([FromBody] UnitTest unitTest)
{
- var newTestRun = new TestRuns();
- newTestRun.Count = Convert.ToInt32(parmeters["Count"]);
- newTestRun.Result = parmeters["Result"].ToString();
- newTestRun.TimeStamp = DateTime.Now.ToString();
-
-
- if(parmeters["Type"].ToString() == "Workspace")
- {
- newTestRun.Type = parmeters["Type"].ToString();
- newTestRun.Workspace = parmeters["Name"].ToString();
- }
- if(parmeters["Type"].ToString() == "TabularModel")
- {
- newTestRun.Type = parmeters["Type"].ToString();
- newTestRun.TabularModel = parmeters["Name"].ToString();
- }
- if(parmeters["Type"].ToString() == "UserStory")
- {
- newTestRun.Type = parmeters["Type"].ToString();
- newTestRun.UserStory = parmeters["Name"].ToString();
- }
+ logger.LogDebug($"Begin: UnitTestsController Post(unitTest Name: {unitTest.Name})");
- base.dbContext.Add(newTestRun);
- base.dbContext.SaveChanges();
- //var Zähler = base.dbContext.Histories.Where(p => p.TimeStamp == newTestRun.TimeStamp).Count();
- /*for(int i = 0; i <= Zähler; i++)
+ if (!ModelState.IsValid)
{
- var newHistory = new History();
- newHistory = base.dbContext.Histories.Where(p => p.TimeStamp == newTestRun.TimeStamp).Where(p => p.TestRun == null).FirstOrDefault();
- newHistory.TestRun = newTestRun.Id;
- base.dbContext.Update(newHistory);
- base.dbContext.SaveChanges();
- }*/
-
- foreach(var History in HistoriesForTestRun)
- {
- var newHistory = new History();
- newHistory = base.dbContext.Histories.Where(p => p.Id == History.Id).FirstOrDefault();
- newHistory.TestRun = newTestRun.Id;
- base.dbContext.Update(newHistory);
- base.dbContext.SaveChanges();
-
+ return BadRequest(ModelState);
}
- HistoriesForTestRun.Clear();
- if(base.dbContext.TestRuns.Where(P => P.Id == newTestRun.Id).FirstOrDefault().HistoriesRun.All(p => p.Result == "True"))
- {
- newTestRun.Result = "True";
- }
- else
- newTestRun.Result = "False";
- base.dbContext.Update(newTestRun);
- base.dbContext.SaveChanges();
- return Ok();
-
- }
+ if ((await this.dbContext.UserStories.FirstOrDefaultAsync(e => e.Id == unitTest.UserStory && e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser)) == null)
+ return Forbid();
- // DELETE: odata/UnitTestsbase
- [HttpDelete]
- public async Task Delete([FromODataUri] int key)
- {
- try
- {
- logger.LogDebug($"Begin: UnitTestsController Delete()");
- var unitTest = await dbContext.UnitTests.FindAsync(key);
+ if (base.dbContext.UnitTests.Any(e => e.Name == unitTest.Name && e.UserStory == unitTest.UserStory))
+ return BadRequest(new ODataError { ErrorCode = "400", Message = "Unit test with the same name already exists in the user story." });
- if (unitTest == null)
- {
- return NotFound();
- }
+ this.dbContext.UnitTests.Add(unitTest);
+ await this.dbContext.SaveChangesAsync();
- base.dbContext.Remove(unitTest);
- base.dbContext.SaveChanges();
+ logger.LogDebug($"End: UnitTestsController Post(unitTest Name: {unitTest.Name})");
- logger.LogDebug($"End: UnitTestsController Delete()");
- return Ok();
- }
- catch (Exception ex)
- {
- logger.LogError(ex, "An error occured while performing DELETE");
- throw;
- }
+ return Created(unitTest);
}
- //????
- public async Task Patch([FromODataUri] int key, Delta unitTest)
- {
- try
- {
- logger.LogDebug($"Begin: UnitTestsController Patch()");
- var unitTestToChange = await base.dbContext.UnitTests.FindAsync(key);
-
- if (unitTestToChange == null)
- {
- return NotFound();
- }
-
- unitTest.Patch(unitTestToChange);
- base.dbContext.SaveChanges();
-
- logger.LogDebug($"End: UnitTestsController Patch()");
- return Updated(unitTestToChange);
- }
- catch (Exception ex)
- {
- logger.LogError(ex, "An error occured while performing PATCH");
- throw;
- }
- }
-
-
- //[ODataRoute("Execute")]
- // public bool bxecute([FromBody] UnitTest unitTestToExecute)
- // {
- // if (!ModelState.IsValid)
- // {
- // var test = "model ungültig";
- // }
- // var testResult = false;
- // dbContext.Add(unitTestToExecute);
- // //await dbContext.SaveChangesAsync();
- // //return Created(unitTestToExecute);
-
-
- // Console.WriteLine($"Unittest {unitTestToExecute.Name} wird hier demnöchst ausgeführt.");
-
- // return testResult;
- // }
-
- [AllowAnonymous]
- [HttpPost]
- public UnitTestExecutionResult Execute([FromBody] object unitTestObject, [FromServices] PowerBiService powerBiService)
+ [HttpDelete]
+ public async Task Delete([FromODataUri] int key)
{
- logger.LogDebug($"Begin: UnitTestController Execute()");
- try
- {
- logger.LogDebug("Executing UnitTest.....");
- var unitTestExecutionResult = new UnitTestExecutionResult();
-
- var structur = JsonConvert.DeserializeObject(unitTestObject.ToString());
-
- var unitTestUpdate = JsonConvert.DeserializeObject(unitTestObject.ToString());
-
- Console.WriteLine($"Unit Test {structur.Name} wird ausgeführt");
-
- var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
- string authToken = powerBiService.GetTokenOnBehalfOf(base.msIdTenantCurrentUser, accessToken).Result;
- Guid datasetId = new Guid(structur.DatasetPbId);//new Guid("1272907a-888e-446f-b89e-037cfaf3f8b5");
- //DatasetId Variable
- History HistoryAdd = new History();
-
- string jsonResponse;
- if (powerBiService.QueryDataset(datasetId, structur.DAX, authToken, out jsonResponse))
- {
-
-
- unitTestExecutionResult.UnitTestExecuted = true;
-
- dynamic TestRersultArray = JsonConvert.DeserializeObject(jsonResponse);
- var TestResult = ((TestRersultArray.results[0].tables[0].rows[0] as JObject).First as JProperty).Value.ToString();
-
- logger.LogDebug($"TestResult: {TestResult}");
-
-
- if (double.TryParse(TestResult, out double testResultDouble))
- {
- TestResult = Math.Round(testResultDouble, 4).ToString();
- logger.LogDebug($"rounded TestResult: {TestResult}");
- }
-
- if (TestResult == structur.ExpectedResult)
- {
- unitTestExecutionResult.UnitTestSucceeded = true;
- }
-
- else
- {
- unitTestExecutionResult.UnitTestSucceeded = false;
- }
-
- logger.LogDebug($"unitTestExecutionResult: {unitTestExecutionResult}");
-
- //unitTestUpdate.LastResult = TestResult;
- UnitTest UnitTestNeu = base.dbContext.UnitTests.Where(p => p.Id == unitTestUpdate.Id).FirstOrDefault();
- UnitTestNeu.LastResult = TestResult;
-
- if(UnitTestNeu.ResultType == "Float")
- {
- float FloatResult;
- FloatResult = float.Parse(TestResult);
- //UnitTestNeu.LastResult = Math.Round(FloatResult, int.Parse(UnitTestNeu.DecimalPlaces)).ToString();
-
+ logger.LogDebug($"Begin: UnitTestsController Delete(key: {key}");
- float roundedValue = (float)Math.Round(FloatResult, int.Parse(UnitTestNeu.DecimalPlaces));
- float round = FloatResult - roundedValue;
+ var unitTest = await this.dbContext.UnitTests.FindAsync(key);
- if (FloatResult - roundedValue >= 0.05)
- {
- roundedValue += (float)Math.Pow(0.1, int.Parse(UnitTestNeu.DecimalPlaces));
- }
+ if (unitTest == null)
+ return NotFound();
- UnitTestNeu.LastResult = roundedValue.ToString();
- UnitTestNeu.LastResult = Math.Round(roundedValue, int.Parse(UnitTestNeu.DecimalPlaces)).ToString();
+ if (unitTest.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId != this.msIdTenantCurrentUser)
+ return Forbid();
+ this.dbContext.UnitTests.Remove(unitTest);
+ await base.dbContext.SaveChangesAsync();
- if(UnitTestNeu.FloatSeparators == "Use Seperators")
- {
- //UnitTestNeu.LastResult.ToString("N");
-
- double number = float.Parse(UnitTestNeu.LastResult);
- UnitTestNeu.LastResult = number.ToString("N");
- }
- }
-
- if(UnitTestNeu.ResultType == "Date")
- {
- DateTime DateResult;
- if(UnitTestNeu.DateTimeFormat == "UTC")
- {
- DateResult = DateTime.Parse(TestResult).ToUniversalTime();
- UnitTestNeu.LastResult = DateResult.ToString();
-
-
-
- }
-
- if(UnitTestNeu.DateTimeFormat == "CET")
- {
- DateResult = DateTime.Parse(TestResult).ToLocalTime();
- UnitTestNeu.LastResult = DateResult.ToString();
- }
-
- }
-
- if(UnitTestNeu.ResultType == "Percentage")
- {
- double number = float.Parse(TestResult);
- UnitTestNeu.LastResult = number.ToString("#0.###%");
-
- }
-
-
- UnitTestNeu.Timestamp = DateTime.Now.ToString();
-
- HistoryAdd.LastRun = UnitTestNeu.LastResult;
- HistoryAdd.ExpectedRun = UnitTestNeu.ExpectedResult;
- HistoryAdd.UnitTest = UnitTestNeu.Id;
- HistoryAdd.Result = unitTestExecutionResult.UnitTestSucceeded.ToString();
- HistoryAdd.TimeStamp = UnitTestNeu.Timestamp;
- HistoriesForTestRun.Add(HistoryAdd);
-
-
- base.dbContext.Add(HistoryAdd);
- base.dbContext.SaveChanges();
-
- base.dbContext.Update(UnitTestNeu);
- base.dbContext.SaveChanges();
- }
-
- //TODO
- /* else if (powerBiService.QueryDataset(datasetId, structur.DAX, authToken, out jsonResponse)){
- unitTestExecutionResult.UnitTestExecuted = false;
- Root2 TestValue;
- TestValue = JsonConvert.DeserializeObject(jsonResponse);
-
- unitTestUpdate.LastResult = TestValue.results[0].tables[0].rows[0].ActualValue.ToString();
- UnitTest UnitTestNeu = new UnitTest();
- UnitTestNeu = base.dbContext.UnitTests.Where(p => p.Name == unitTestUpdate.Name).FirstOrDefault();
- UnitTestNeu.LastResult = unitTestUpdate.LastResult;
-
- DateTime Timestamp = new DateTime();
- Timestamp = DateTime.Now;
- UnitTestNeu.Timestamp = Timestamp.ToString();
-
- HistoryAdd.LastRun = UnitTestNeu.LastResult;
- HistoryAdd.ExpectedRun = UnitTestNeu.ExpectedResult;
- HistoryAdd.UnitTest = UnitTestNeu.Id;
- HistoryAdd.TimeStamp = UnitTestNeu.Timestamp;
- HistoryAdd.Result = "False";
-
- base.dbContext.Add(HistoryAdd);
- base.dbContext.SaveChanges();
-
-
- base.dbContext.Update(UnitTestNeu);
- base.dbContext.SaveChanges();
- }*/
-
-
-
- logger.LogDebug($"End: UnitTestController Execute(Return: {unitTestExecutionResult})");
- return unitTestExecutionResult;
- }
- catch (Exception ex)
- {
- logger.LogDebug(ex, "An error occured while Executing the UnitTest(Controller)");
- throw;
- }
+ logger.LogDebug($"End: UnitTestsController Delete(key: {key}");
+ return Ok();
}
- [AllowAnonymous]
- [HttpPost]
- public async Task LoadWorkspace([FromServices] PowerBiService powerBiService, Root TestValue, Root3 TestDataset)
+ [HttpPatch]
+ public async Task Patch([FromODataUri] int key, Delta unitTest)
{
- try
- {
- logger.LogDebug($"Begin: UnitTestsController LoadWorkspaces()");
- logger.LogDebug("Sycing or Loading Workspaces");
- LW(powerBiService, out TestValue);
-
- int Zähler;
- Zähler = TestValue.OdataCount;
- for (int i = 0; i <= Zähler - 1; i++)
- {
- Workspace AddWorkspace = new Workspace();
- string Json2;
-
-
- //using (var db = new PortalDbContext())
-
-
- var Test = TestValue.Values.ElementAt(i);
- var TestWorkspace = base.dbContext.Workspaces.Where(p => p.WorkspacePbId == Test.id).FirstOrDefault();
-
+ logger.LogDebug($"Begin: UnitTestsController Patch(key: {key}, unitTest: {unitTest.GetChangedPropertyNames()}");
- if (TestWorkspace == null)
- {
- AddWorkspace.Name = TestValue.Values.ElementAt(i).name;
- AddWorkspace.WorkspacePbId = TestValue.Values.ElementAt(i).id;
+ if ((await this.dbContext.UnitTests.FirstOrDefaultAsync(e => e.Id == key && e.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser)) == null)
+ return Forbid();
- base.dbContext.Add(AddWorkspace);
- base.dbContext.SaveChanges();
-
- }
-
- else if (TestWorkspace != null)
- {
- if (Test.name != TestWorkspace.Name)
- {
- TestWorkspace.Name = Test.name;
- }
-
- base.dbContext.Update(TestWorkspace);
- }
-
- LoadDataset(TestValue.Values.ElementAt(i).id, powerBiService, out TestDataset);
-
- int Zähler2;
- Zähler2 = TestDataset.Values.Count - 1;
-
- if (Zähler2 >= 0)
- {
- for (int k = 0; k <= Zähler2; k++)
- {
- TabularModel AddTabModel = new TabularModel();
-
- var DatasetTestId = TestDataset.Values.ElementAt(k).id;
- var TestTabModel = base.dbContext.TabularModels.Where(p => p.DatasetPbId == DatasetTestId).FirstOrDefault();
-
- if (TestTabModel == null)
- {
- AddWorkspace.WorkspacePbId = TestValue.Values.ElementAt(i).id;
- AddTabModel.DatasetPbId = TestDataset.Values.ElementAt(k).id;
- AddTabModel.Workspace = base.dbContext.Workspaces.Where(p => p.WorkspacePbId == AddWorkspace.WorkspacePbId).FirstOrDefault().Id;
- AddTabModel.Name = TestDataset.Values.ElementAt(k).name;
-
- base.dbContext.Add(AddTabModel);
- var test = base.dbContext.Workspaces.Where(e => e.Name == null);
- base.dbContext.SaveChanges();
- }
-
- else if (TestTabModel != null)
- {
- AddWorkspace.WorkspacePbId = TestValue.Values.ElementAt(i).id;
- if (TestDataset.Values.ElementAt(k).id != base.dbContext.TabularModels.Where(p => p.DatasetPbId == TestDataset.Values.ElementAt(k).id).FirstOrDefault().DatasetPbId)
- {
- TestTabModel.DatasetPbId = TestDataset.Values.ElementAt(k).id;
- }
-
- //if(TestDataset.Values.ElementAt(k).name != base.dbContext.TabularModels.Where(p => p.Name == TestDataset.Values.ElementAt(k).name).FirstOrDefault().Name)
- //TestTabModel.Name = TestDataset.Values.ElementAt(k).name;
-
- var tabularModel = base.dbContext.TabularModels.FirstOrDefault(p => p.Name == TestDataset.Values.ElementAt(k).name);
- if (tabularModel != null && TestDataset.Values.ElementAt(k).name != null)
- {
- if (TestDataset.Values.ElementAt(k).name != tabularModel.Name)
- {
- TestTabModel.Name = TestDataset.Values.ElementAt(k).name;
- }
- }
- else
- {
-
- }
-
-
- base.dbContext.Update(TestTabModel);
- }
- }
- }
- }
- base.dbContext.SaveChanges();
-
- logger.LogDebug($"End: UnitTestController LoadDataset()");
-
- return Ok();
+ if (!ModelState.IsValid)
+ {
+ return BadRequest(ModelState);
}
- catch (Exception ex)
+ var entity = await base.dbContext.UnitTests.FindAsync(key);
+ if (entity == null)
{
- logger.LogError(ex, "An error occured while Sycning or Loading Workspaces");
- throw;
+ return NotFound();
}
- }
- public Root3 LoadDataset(string DatasetPbId, [FromServices] PowerBiService powerBiService, out Root3 TestDataset)
- {
- logger.LogDebug($"Begin: UnitTestsController LoadDataset()");
- var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
- string authToken = powerBiService.GetTokenOnBehalfOf(base.msIdTenantCurrentUser, accessToken).Result;
- string jsonResponse;
+ unitTest.Patch(entity);
- if (powerBiService.LoadDataset(DatasetPbId, authToken, out jsonResponse))
- {
- TestDataset = JsonConvert.DeserializeObject(jsonResponse);
- }
+ if (base.dbContext.UnitTests.Any(e => e.Name == entity.Name && e.UserStory == entity.UserStory && e.Id != entity.Id))
+ return BadRequest(new ODataError { ErrorCode = "400", Message = "Unit test with the same name already exists in the user story." });
- else
- {
- TestDataset = new Root3();
- }
+ await base.dbContext.SaveChangesAsync();
+
+ logger.LogDebug($"End: UnitTestsController Patch(key: {key}, unitTest: {unitTest.GetChangedPropertyNames()}");
- logger.LogDebug($"End: UnitTestsController LoadDataset()");
- return TestDataset;
+ return Updated(entity);
}
- public Root LW([FromServices] PowerBiService powerBiService, out Root TestValue)
+ [HttpPost]
+ public async Task Execute([FromBody] ODataActionParameters parmeters, [FromServices] UnitTestService unitTestService)
{
- logger.LogDebug($"Start: UnitTestsController LW()");
-
- var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
- string authToken = powerBiService.GetTokenOnBehalfOf(base.msIdTenantCurrentUser, accessToken).Result;
- string jsonResponse;
- //Root TestValue;
-
- if (powerBiService.LoadWorkspace(authToken, out jsonResponse))
- {
+ logger.LogDebug($"Begin: UnitTestsController Execute()");
- TestValue = JsonConvert.DeserializeObject(jsonResponse);
- }
+ var unitTestIds = parmeters["unitTestIds"] as IEnumerable;
- else
- {
- TestValue = new Root();
- }
+ var accessToken = httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
+ await unitTestService.ExecuteMultipe(msIdTenantCurrentUser, accessToken, unitTestIds);
- logger.LogDebug($"End: UnitTestsController LW()");
- return TestValue;
+ logger.LogDebug($"End: UnitTestsController Execute()");
+ return Ok();
}
}
}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UserStoriesController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UserStoriesController.cs
index 9913972..0232b0a 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UserStoriesController.cs
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UserStoriesController.cs
@@ -18,6 +18,7 @@
using Microsoft.AspNetCore.OData.Deltas;
using Microsoft.EntityFrameworkCore;
using at.PowerBIUnitTest.Portal.Services;
+using System.Collections.Generic;
namespace at.PowerBIUnitTest.Portal.Controllers
{
@@ -25,163 +26,136 @@ namespace at.PowerBIUnitTest.Portal.Controllers
[Authorize]
public class UserStoriesController : BaseController
{
- private readonly IConfiguration configuration;
- private readonly ILogger logger;
- public UserStoriesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor)
+ public UserStoriesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger)
{
- this.configuration = configuration;
- this.logger = logger;
}
-
+ [EnableQuery]
+ public IQueryable Get([FromODataUri] int key)
+ {
+ logger.LogDebug($"Begin & End: UserStoriesController Get(key: {key})");
+ return base.dbContext.UserStories.Where(e => e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key);
+ }
+
[EnableQuery]
public IQueryable Get()
{
logger.LogDebug($"Begin & End: UserStoriesController Get()");
- return base.dbContext.UserStories;
+ return base.dbContext.UserStories.Where(e => e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser);
}
- // Add odata/UserStory
[HttpPost]
- public UserStory Post([FromBody] UserStory userStory)
+ public async Task Post([FromBody] UserStory userStory)
{
- try
- {
- logger.LogDebug($"Begin: UserStoriesController Post()");
- var newUserStory = base.dbContext.Add(userStory);
- base.dbContext.SaveChanges();
- logger.LogDebug($"End: UserStoriesController Post()");
- return newUserStory.Entity;
- }
- catch(Exception ex)
+ logger.LogDebug($"Begin: UserStoriesController Post(unitTest Description: {userStory.Name})");
+
+ if (!ModelState.IsValid)
{
- logger.LogError(ex, "An error occured while adding a User Story");
- throw;
+ return BadRequest(ModelState);
}
- }
- public async Task Patch([FromODataUri] int key, Delta userStory)
- {
- try
- {
- logger.LogDebug($"Begin: UnitTestsController Patch()");
- var userStoryToChange = await base.dbContext.UserStories.FindAsync(key);
+ if ((await this.dbContext.TabularModels.FirstOrDefaultAsync(e => e.Id == userStory.TabularModel && e.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser)) == null)
+ return Forbid();
- if (userStoryToChange == null)
- {
- return NotFound();
- }
+ this.dbContext.UserStories.Add(userStory);
+ await this.dbContext.SaveChangesAsync();
- userStory.Patch(userStoryToChange);
- base.dbContext.SaveChanges();
+ logger.LogDebug($"End: UserStoriesController Post(unitTest Description: {userStory.Name})");
- logger.LogDebug($"End: UnitTestsController Patch()");
- return Updated(userStoryToChange);
- }
- catch (Exception ex)
- {
- logger.LogError(ex, "An error occured while performing PATCH");
- throw;
- }
+ return Created(userStory);
}
- [HttpPost]
- public async Task Copy ([FromODataUri] int key, ODataActionParameters parameters)
+ [HttpDelete]
+ public async Task Delete([FromODataUri] int key)
{
- logger.LogDebug($"Begin: UserStoriesController Copy(key: {key})");
- /*
- var solution = await this.dbContext.UserStories.FirstOrDefaultAsync(e => e.Id == key && e.TabularModelNavigation.WorkspaceNavigation..DevelopmentEnvironmentNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser);
- if (solution == null)
+ logger.LogDebug($"Begin: UserStoriesController Delete(key: {key}");
+
+ var userStory = await this.dbContext.UserStories.FindAsync(key);
+
+ if (userStory == null)
+ return NotFound();
+
+ if (userStory.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId != this.msIdTenantCurrentUser)
return Forbid();
- if (solution.IsPatch())
- return BadRequest("Can't apply upgrade for patch solution");
+ this.dbContext.UserStories.Remove(userStory);
+ await base.dbContext.SaveChangesAsync();
- int targetEnvironmentId = (int)parameters["targetEnvironmentId"];
- if (ImportExistsOnEnvironment(key, targetEnvironmentId) == false)
- return BadRequest("Can't skip import before applying an upgrade");
+ logger.LogDebug($"End: UserStoriesController Delete(key: {key}");
+ return Ok();
+ }
- Data.Models.Action createdAction;
+ [HttpPatch]
+ public async Task Patch([FromODataUri] int key, Delta userStory)
+ {
+ logger.LogDebug($"Begin: UserStoriesController Patch(key: {key}, userStory: {userStory.GetChangedPropertyNames()}");
- try
+ if ((await this.dbContext.UserStories.FirstOrDefaultAsync(e => e.Id == key && e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser)) == null)
+ return Forbid();
+
+ if (!ModelState.IsValid)
{
- createdAction = await solutionService.AddApplyUpgradeAction(key, targetEnvironmentId, this.msIdCurrentUser);
+ return BadRequest(ModelState);
}
- catch (Exception e)
+ var entity = await base.dbContext.UserStories.FindAsync(key);
+ if (entity == null)
{
- return BadRequest(e.Message);
+ return NotFound();
}
- logger.LogDebug($"End: SolutionsController ApplyUpgrade()");
- */
-
-
- return Ok();
- }
-[HttpPost]
-public async Task Copy2 ([FromODataUri] int key, ODataActionParameters parameters)
-{
- try
- {
- int targetTabularModelId = (int)parameters["targetTabularModelId1"];
- int targetWorkspaceId = (int)parameters["targetWorkspaceId1"];
- int originalUserStoryId = (int)parameters["userStoryId1"];
+ userStory.Patch(entity);
+ await base.dbContext.SaveChangesAsync();
- // 1. UserStory kopieren
- var originalUserStory = await base.dbContext.UserStories
- .Include(us => us.UnitTests) // Include, um die verknüpften UnitTests abzurufen
- .FirstOrDefaultAsync(us => us.Id == originalUserStoryId);
+ logger.LogDebug($"End: UserStoriesController Patch(key: {key}, userStory: {userStory.GetChangedPropertyNames()}");
- if (originalUserStory == null)
- {
- return NotFound();
+ return Updated(entity);
}
- var copiedUserStory = new UserStory
+ [HttpPost]
+ public async Task Copy([FromODataUri] int key, ODataActionParameters parameters)
{
- Beschreibung = originalUserStory.Beschreibung,
- TabularModel = targetTabularModelId,
- };
+ logger.LogDebug($"Begin: UserStoriesController Copy(key: {key})");
- base.dbContext.UserStories.Add(copiedUserStory);
- base.dbContext.SaveChanges();
+ int targetTabularModelId = (int)parameters["targetTabularModelId"];
- // 2. UnitTests kopieren
- foreach (var originalUnitTest in originalUserStory.UnitTests)
- {
- var copiedUnitTest = new UnitTest
+ var originalUserStory = await base.dbContext.UserStories.FirstOrDefaultAsync(e => e.Id == key && e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser);
+ var tabularModel = await base.dbContext.TabularModels.FirstOrDefaultAsync(e => e.Id == targetTabularModelId && e.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser);
+
+ if (originalUserStory == null || tabularModel == null)
+ {
+ return NotFound();
+ }
+
+ var copiedUserStory = new UserStory
{
- // Kopieren Sie alle erforderlichen Eigenschaften des UnitTests
- // ...
-
- // Aktualisieren Sie die Beziehung zur kopierten UserStory
- Name = originalUnitTest.Name,
- DAX = originalUnitTest.DAX,
- ExpectedResult = originalUnitTest.ExpectedResult,
- ResultType = originalUnitTest.ResultType,
- DateTimeFormat = originalUnitTest.DateTimeFormat,
- DecimalPlaces = originalUnitTest.DecimalPlaces,
- FloatSeparators = originalUnitTest.FloatSeparators,
- Timestamp = originalUnitTest.Timestamp,
- UserStory = copiedUserStory.Id,
+ Name = originalUserStory.Name,
+ TabularModel = targetTabularModelId,
};
- dbContext.UnitTests.Add(copiedUnitTest);
- }
+ var copiedUnitTests = new List();
- dbContext.SaveChanges();
+ foreach (var originalUnitTest in originalUserStory.UnitTests)
+ {
+ var copiedUnitTest = new UnitTest
+ {
+ Name = originalUnitTest.Name,
+ DAX = originalUnitTest.DAX,
+ ExpectedResult = originalUnitTest.ExpectedResult,
+ ResultType = originalUnitTest.ResultType,
+ DateTimeFormat = originalUnitTest.DateTimeFormat,
+ DecimalPlaces = originalUnitTest.DecimalPlaces,
+ FloatSeparators = originalUnitTest.FloatSeparators,
+ };
+
+ copiedUnitTests.Add(copiedUnitTest);
+ }
- logger.LogDebug($"End: UserStoriesController Copy()");
- return Ok();
- }
- catch (Exception ex)
- {
- logger.LogError(ex, "An error occurred while copying UserStory");
- throw;
- }
-}
+ copiedUserStory.UnitTests = copiedUnitTests;
+ base.dbContext.UserStories.Add(copiedUserStory);
+ await dbContext.SaveChangesAsync();
+ logger.LogDebug($"End: UserStoriesController Copy()");
+ return Ok();
+ }
}
-
-
}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UsersController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UsersController.cs
index 8b23959..0783692 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UsersController.cs
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UsersController.cs
@@ -26,13 +26,15 @@ namespace at.PowerBIUnitTest.Portal.Controllers
{
public class UsersController : BaseController
{
+ public UsersController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger)
+ {
+ }
- private readonly IConfiguration configuration;
- private readonly ILogger logger;
- public UsersController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor)
+ [EnableQuery]
+ public IQueryable Get([FromODataUri] int key)
{
- this.configuration = configuration;
- this.logger = logger;
+ logger.LogDebug($"Begin & End: UsersController Get(key: {key})");
+ return base.dbContext.Users.Where(e => e.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key);
}
// GET: odata/Users
@@ -64,6 +66,9 @@ public async Task Login([FromServices] IConfiguration configurati
if (string.IsNullOrEmpty(currentUser.Firstname))
currentUser.Firstname = currentUser.Email;
+ if (string.IsNullOrEmpty(currentUser.Lastname))
+ currentUser.Lastname = string.Empty;
+
Guid msIdTenantCurrentUser = Guid.Parse(this.HttpContext.User.FindFirst(ClaimConstants.TenantId).Value);
//check if current user exists in database
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/WorkspacesController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/WorkspacesController.cs
index 87529cd..b8fa023 100644
--- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/WorkspacesController.cs
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/WorkspacesController.cs
@@ -23,143 +23,35 @@ namespace at.PowerBIUnitTest.Portal.Controllers
public class WorkspacesController : BaseController
{
- private readonly IConfiguration configuration;
-
- private IHttpContextAccessor _httpContextAccessor;
- private readonly ILogger logger;
- public WorkspacesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor)
+ public WorkspacesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger)
{
- this.configuration = configuration;
- _httpContextAccessor = httpContextAccessor;
- this.logger = logger;
}
- [AllowAnonymous]
- [HttpPost]
[EnableQuery(MaxExpansionDepth = 4)]
- public IQueryable FilterWorkspace([FromServices] PowerBiService powerBiService)
+ public IQueryable Get([FromODataUri] int key)
{
- logger.LogDebug($"Begin: WorkspaceController FilterWorkspace()");
- try
- {
- logger.LogDebug("Filtering Workspace....");
- var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
- string authToken = powerBiService.GetTokenOnBehalfOf(base.msIdTenantCurrentUser, accessToken).Result;
- string jsonResponse;
- Workspace[] abcd = new Workspace[0];
- //Root TestValue;
-
- if (powerBiService.LoadWorkspace(authToken, out jsonResponse)){
- Root TestValue = new Root();
- TestValue = JsonConvert.DeserializeObject(jsonResponse);
- int Zähler;
- Zähler = TestValue.OdataCount;
- abcd = new Workspace[Zähler];
-
- for (int i = 0; i <= Zähler - 1; i++){
-
- Workspace Füller;
- TabularModel[] FüllerTB;
-
- Füller = new Workspace();
- FüllerTB = new TabularModel[1];
- Root3 TestDataset = new Root3();
-
- if(powerBiService.LoadDataset(TestValue.Values.ElementAt(i).id, authToken, out jsonResponse)){
- TestDataset = JsonConvert.DeserializeObject(jsonResponse);
- int zähler2;
- zähler2 = TestDataset.Values.Count();
-
- FüllerTB = new TabularModel[zähler2];
- TabularModel FüllerTB2 = new TabularModel();
- for (int k = 0; k <= zähler2 - 1; k++){
- FüllerTB2.DatasetPbId = TestDataset.Values.ElementAt(k).id;
- //FüllerTB2.Id = this.dbContext.TabularModels.Where(p => p.DatasetPbId == FüllerTB2.DatasetPbId).FirstOrDefault().Id;
-
- FüllerTB[k] = FüllerTB2;
- }
- }
-
- Füller.WorkspacePbId = TestValue.Values.ElementAt(i).id;
- Füller.Name = TestValue.Values.ElementAt(i).name;
- // Füller.Id = TestValue.Values.ElementAt(i).id;
- Füller.TabularModels = FüllerTB;
- abcd[i] = Füller;
- }
-
- IQueryable qtest = abcd.AsQueryable();
-
- return qtest;
- }
-
- Workspace[] dings = new Workspace[1];
-
-
-
- var workspaces = dings.AsQueryable();
- logger.LogDebug($"End: WorkspaceController FilterWorkspace(Return: {workspaces})");
- return workspaces;
-
-
- }
- catch(Exception ex)
- {
- logger.LogError(ex, "An error occured while performing FilterWorkspace");
- throw;
- }
+ logger.LogDebug($"Begin & End: WorkspacesController Get(key: {key})");
+ return base.dbContext.Workspaces.Where(e => e.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key);
}
-
[EnableQuery(MaxExpansionDepth = 4)]
- public IQueryable Get([FromServices] PowerBiService powerBiService){
- /*var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
- string authToken = powerBiService.GetTokenOnBehalfOf(accessToken).Result;
- string jsonResponse;
-
- if(powerBiService.LoadWorkspace(authToken, out jsonResponse))
- {
- Root TestValue = new Root();
- TestValue = JsonConvert.DeserializeObject(jsonResponse);
- int Zähler2;
- Zähler2 = TestValue.OdataCount;
-
-
- Workspace[] Filter = new Workspace[Zähler2];
- //FilterWorkspace(powerBiService, out Filter);
- string[] TestFilter = new string[0];
-
-
- return base.dbContext.Workspaces;*/
+ public IQueryable Get()
+ {
logger.LogDebug($"Begin & End: WorkspacesController Get()");
-
- return base.dbContext.Workspaces;
-
+ return base.dbContext.Workspaces.Where(e => e.TenantNavigation.MsId == this.msIdTenantCurrentUser);
}
- [HttpDelete]
- public async Task Delete([FromODataUri] int key)
- {
- try
- {
- logger.LogDebug($"Begin: UnitTestsController Delete()");
- var workspace = await dbContext.Workspaces.FindAsync(key);
-
- if (workspace == null)
- {
- return NotFound();
- }
+ [HttpPost]
+ public async Task Pull([FromServices] WorkspaceService workspaceService, [FromServices] TabularModelService tabularModelService)
+ {
+ logger.LogDebug($"Begin: WorkspacesController Pull()");
- base.dbContext.Remove(workspace);
- base.dbContext.SaveChanges();
+ var accessToken = httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
+ await workspaceService.PullWorkspacesFromPowerBi(msIdTenantCurrentUser, accessToken);
+ await tabularModelService.PullDatasetsFromPowerBi(msIdTenantCurrentUser, accessToken);
- logger.LogDebug($"End: UnitTestsController Delete()");
- return Ok();
- }
- catch (Exception ex)
- {
- logger.LogError(ex, "An error occured while performing DELETE");
- throw;
- }
+ logger.LogDebug($"End: WorkspacesController Pull()");
+ return Ok();
}
}
}
\ No newline at end of file
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.Designer.cs
new file mode 100644
index 0000000..71c802d
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.Designer.cs
@@ -0,0 +1,602 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using at.PowerBIUnitTest.Portal.Data.Models;
+
+#nullable disable
+
+namespace at.PowerBIUnitTest.Portal.Data.Migrations
+{
+ [DbContext(typeof(PortalDbContext))]
+ [Migration("20240411151522_RemakeModel")]
+ partial class RemakeModel
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .UseCollation("SQL_Latin1_General_CP1_CI_AS")
+ .HasAnnotation("ProductVersion", "6.0.1")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.History", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("CreatedBy")
+ .HasColumnType("int");
+
+ b.Property("CreatedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("ExpectedRun")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("Expected Result");
+
+ b.Property("LastRun")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("LastRun");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("int");
+
+ b.Property("ModifiedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("Result")
+ .HasColumnType("bit")
+ .HasColumnName("WasPassed");
+
+ b.Property("TestRun")
+ .HasColumnType("int");
+
+ b.Property("TimeStamp")
+ .HasColumnType("datetime2")
+ .HasColumnName("TimeStamp");
+
+ b.Property("UnitTest")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreatedBy");
+
+ b.HasIndex("ModifiedBy");
+
+ b.HasIndex("TestRun");
+
+ b.HasIndex("UnitTest");
+
+ b.ToTable("TestRun", (string)null);
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("Name");
+
+ b.HasKey("Id");
+
+ b.ToTable("ResultType", (string)null);
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Name = "Date"
+ },
+ new
+ {
+ Id = 2,
+ Name = "Float"
+ },
+ new
+ {
+ Id = 3,
+ Name = "Percentage"
+ },
+ new
+ {
+ Id = 4,
+ Name = "String"
+ });
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(255)
+ .IsUnicode(false)
+ .HasColumnType("int")
+ .HasColumnName("Id");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("DatasetPbId")
+ .HasColumnType("uniqueidentifier")
+ .HasColumnName("Ms Id");
+
+ b.Property("Name")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("Name");
+
+ b.Property("Workspace")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Workspace");
+
+ b.ToTable("TabularModel", (string)null);
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("MsId")
+ .HasColumnType("uniqueidentifier")
+ .HasColumnName("MS Id");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Tenant", (string)null);
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("CreatedBy")
+ .HasColumnType("int");
+
+ b.Property("CreatedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("int");
+
+ b.Property("ModifiedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("TimeStamp")
+ .HasColumnType("datetime2")
+ .HasColumnName("TimeStamp");
+
+ b.Property("WasPassed")
+ .IsRequired()
+ .HasMaxLength(255)
+ .IsUnicode(false)
+ .HasColumnType("varchar(255)")
+ .HasColumnName("Result");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreatedBy");
+
+ b.HasIndex("ModifiedBy");
+
+ b.ToTable("TestRunCollection", (string)null);
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("CreatedBy")
+ .HasColumnType("int");
+
+ b.Property("CreatedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("DAX")
+ .IsRequired()
+ .HasMaxLength(3000)
+ .IsUnicode(true)
+ .HasColumnType("nvarchar(3000)")
+ .HasColumnName("DAX")
+ .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8");
+
+ b.Property("DateTimeFormat")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("DateTimeFormat");
+
+ b.Property("DecimalPlaces")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("DecimalPlaces");
+
+ b.Property("ExpectedResult")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("Expected Result");
+
+ b.Property("FloatSeparators")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("FloatSeparators");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("int");
+
+ b.Property("ModifiedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("Name");
+
+ b.Property("ResultType")
+ .HasColumnType("int");
+
+ b.Property("UserStory")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreatedBy");
+
+ b.HasIndex("ModifiedBy");
+
+ b.HasIndex("ResultType");
+
+ b.HasIndex("UserStory");
+
+ b.HasIndex("Name", "UserStory")
+ .IsUnique();
+
+ b.ToTable("UnitTest", (string)null);
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Email")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("Firstname")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("Lastname")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("MsId")
+ .HasColumnType("uniqueidentifier")
+ .HasColumnName("MS Id");
+
+ b.Property("Tenant")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tenant");
+
+ b.ToTable("User", (string)null);
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Beschreibung")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("Description");
+
+ b.Property("CreatedBy")
+ .HasColumnType("int");
+
+ b.Property("CreatedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("int");
+
+ b.Property("ModifiedOn")
+ .HasColumnType("datetime2");
+
+ b.Property("TabularModel")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CreatedBy");
+
+ b.HasIndex("ModifiedBy");
+
+ b.HasIndex("TabularModel");
+
+ b.ToTable("UserStory", (string)null);
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)")
+ .HasColumnName("Name");
+
+ b.Property("TenantNavigationId")
+ .HasColumnType("int");
+
+ b.Property("WorkspacePbId")
+ .HasColumnType("uniqueidentifier")
+ .HasColumnName("Ms Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantNavigationId");
+
+ b.ToTable("Workspace", (string)null);
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.History", b =>
+ {
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation")
+ .WithMany("TestRunCreatedByNavigations")
+ .HasForeignKey("CreatedBy")
+ .IsRequired()
+ .HasConstraintName("FK_TestRun_Created_By");
+
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation")
+ .WithMany("TestRunModifiedByNavigations")
+ .HasForeignKey("ModifiedBy")
+ .IsRequired()
+ .HasConstraintName("FK_TestRun_Modified_By");
+
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", "TestRunCollectionNavigation")
+ .WithMany("TestRunsDummy")
+ .HasForeignKey("TestRun");
+
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation")
+ .WithMany("TestRuns")
+ .HasForeignKey("UnitTest")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("CreatedByNavigation");
+
+ b.Navigation("ModifiedByNavigation");
+
+ b.Navigation("TestRunCollectionNavigation");
+
+ b.Navigation("UnitTestNavigation");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b =>
+ {
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation")
+ .WithMany("TabularModels")
+ .HasForeignKey("Workspace")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("WorkspaceNavigation");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b =>
+ {
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation")
+ .WithMany("TestRunCollectionCreatedByNavigations")
+ .HasForeignKey("CreatedBy")
+ .IsRequired()
+ .HasConstraintName("FK_TestRunCollection_Created_By");
+
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation")
+ .WithMany("TestRunCollectionModifiedByNavigations")
+ .HasForeignKey("ModifiedBy")
+ .IsRequired()
+ .HasConstraintName("FK_TestRunCollection_Modified_By");
+
+ b.Navigation("CreatedByNavigation");
+
+ b.Navigation("ModifiedByNavigation");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b =>
+ {
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation")
+ .WithMany("UnitTestCreatedByNavigations")
+ .HasForeignKey("CreatedBy")
+ .IsRequired()
+ .HasConstraintName("FK_UnitTest_Created_By");
+
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation")
+ .WithMany("UnitTestModifiedByNavigations")
+ .HasForeignKey("ModifiedBy")
+ .IsRequired()
+ .HasConstraintName("FK_UnitTest_Modified_By");
+
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation")
+ .WithMany("UnitTests")
+ .HasForeignKey("ResultType")
+ .IsRequired();
+
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation")
+ .WithMany("UnitTests")
+ .HasForeignKey("UserStory")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("CreatedByNavigation");
+
+ b.Navigation("ModifiedByNavigation");
+
+ b.Navigation("ResultTypeNavigation");
+
+ b.Navigation("UserStoryNavigation");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b =>
+ {
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation")
+ .WithMany("Users")
+ .HasForeignKey("Tenant")
+ .IsRequired();
+
+ b.Navigation("TenantNavigation");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b =>
+ {
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation")
+ .WithMany("UserStoryCreatedByNavigations")
+ .HasForeignKey("CreatedBy")
+ .IsRequired()
+ .HasConstraintName("FK_UserStory_Created_By");
+
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation")
+ .WithMany("UserStoryModifiedByNavigations")
+ .HasForeignKey("ModifiedBy")
+ .IsRequired()
+ .HasConstraintName("FK_UserStory_Modified_By");
+
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation")
+ .WithMany("UserStories")
+ .HasForeignKey("TabularModel")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("CreatedByNavigation");
+
+ b.Navigation("ModifiedByNavigation");
+
+ b.Navigation("TabularModelNavigation");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b =>
+ {
+ b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation")
+ .WithMany("Workspaces")
+ .HasForeignKey("TenantNavigationId");
+
+ b.Navigation("TenantNavigation");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b =>
+ {
+ b.Navigation("UnitTests");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b =>
+ {
+ b.Navigation("UserStories");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b =>
+ {
+ b.Navigation("Users");
+
+ b.Navigation("Workspaces");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b =>
+ {
+ b.Navigation("TestRunsDummy");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b =>
+ {
+ b.Navigation("TestRuns");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b =>
+ {
+ b.Navigation("TestRunCollectionCreatedByNavigations");
+
+ b.Navigation("TestRunCollectionModifiedByNavigations");
+
+ b.Navigation("TestRunCreatedByNavigations");
+
+ b.Navigation("TestRunModifiedByNavigations");
+
+ b.Navigation("UnitTestCreatedByNavigations");
+
+ b.Navigation("UnitTestModifiedByNavigations");
+
+ b.Navigation("UserStoryCreatedByNavigations");
+
+ b.Navigation("UserStoryModifiedByNavigations");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b =>
+ {
+ b.Navigation("UnitTests");
+ });
+
+ modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b =>
+ {
+ b.Navigation("TabularModels");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.cs
new file mode 100644
index 0000000..c7ad638
--- /dev/null
+++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.cs
@@ -0,0 +1,1209 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace at.PowerBIUnitTest.Portal.Data.Migrations
+{
+ public partial class RemakeModel : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_UnitTest_ResultType_ResultType",
+ table: "UnitTest");
+
+ migrationBuilder.Sql("UPDATE UnitTest SET ResultType = 1 WHERE ResultType = 'Date'");
+ migrationBuilder.Sql("UPDATE UnitTest SET ResultType = 2 WHERE ResultType = 'Float'");
+ migrationBuilder.Sql("UPDATE UnitTest SET ResultType = 3 WHERE ResultType = 'Percentage'");
+ migrationBuilder.Sql("UPDATE UnitTest SET ResultType = 4 WHERE ResultType = 'String'");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_History_TestRuns_TestRun",
+ table: "History");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_History_UnitTest_UnitTest",
+ table: "History");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_ResultType",
+ table: "ResultType");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_TestRuns",
+ table: "TestRuns");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_History",
+ table: "History");
+
+ migrationBuilder.Sql("TRUNCATE TABLE History");
+ migrationBuilder.Sql("TRUNCATE TABLE TestRuns");
+
+ migrationBuilder.DeleteData(
+ table: "ResultType",
+ keyColumn: "Name",
+ keyValue: "Date");
+
+ migrationBuilder.DeleteData(
+ table: "ResultType",
+ keyColumn: "Name",
+ keyValue: "Float");
+
+ migrationBuilder.DeleteData(
+ table: "ResultType",
+ keyColumn: "Name",
+ keyValue: "Percentage");
+
+ migrationBuilder.DeleteData(
+ table: "ResultType",
+ keyColumn: "Name",
+ keyValue: "String");
+
+ migrationBuilder.DropColumn(
+ name: "LastResult",
+ table: "UnitTest");
+
+ migrationBuilder.DropColumn(
+ name: "LastRun",
+ table: "UnitTest");
+
+ migrationBuilder.DropColumn(
+ name: "Count",
+ table: "TestRuns");
+
+ migrationBuilder.DropColumn(
+ name: "TabularModel",
+ table: "TestRuns");
+
+ migrationBuilder.DropColumn(
+ name: "Type",
+ table: "TestRuns");
+
+ migrationBuilder.DropColumn(
+ name: "UserStory",
+ table: "TestRuns");
+
+ migrationBuilder.DropColumn(
+ name: "Workspace",
+ table: "TestRuns");
+
+ migrationBuilder.RenameTable(
+ name: "TestRuns",
+ newName: "TestRunCollection");
+
+ migrationBuilder.RenameTable(
+ name: "History",
+ newName: "TestRun");
+
+ migrationBuilder.RenameColumn(
+ name: "WorkspacePbId",
+ table: "Workspace",
+ newName: "Ms Id");
+
+ migrationBuilder.RenameColumn(
+ name: "Beschreibung",
+ table: "UserStory",
+ newName: "Description");
+
+ migrationBuilder.RenameColumn(
+ name: "ExpectedResult",
+ table: "UnitTest",
+ newName: "Expected Result");
+
+ migrationBuilder.RenameColumn(
+ name: "DatasetPbId",
+ table: "TabularModel",
+ newName: "Ms Id");
+
+ migrationBuilder.RenameColumn(
+ name: "Result",
+ table: "TestRun",
+ newName: "WasPassed");
+
+ migrationBuilder.RenameColumn(
+ name: "ExpectedRun",
+ table: "TestRun",
+ newName: "Expected Result");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_History_UnitTest",
+ table: "TestRun",
+ newName: "IX_TestRun_UnitTest");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_History_TestRun",
+ table: "TestRun",
+ newName: "IX_TestRun_TestRun");
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "Workspace",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "Ms Id",
+ table: "Workspace",
+ type: "uniqueidentifier",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AddColumn(
+ name: "TenantNavigationId",
+ table: "Workspace",
+ type: "int",
+ nullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "UserStory",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AddColumn(
+ name: "CreatedBy",
+ table: "UserStory",
+ type: "int",
+ nullable: true,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "CreatedOn",
+ table: "UserStory",
+ type: "datetime2",
+ nullable: true,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "ModifiedBy",
+ table: "UserStory",
+ type: "int",
+ nullable: true,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "ModifiedOn",
+ table: "UserStory",
+ type: "datetime2",
+ nullable: true,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AlterColumn(
+ name: "Lastname",
+ table: "User",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "varchar(100)",
+ oldUnicode: false,
+ oldMaxLength: 100,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "Firstname",
+ table: "User",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "Email",
+ table: "User",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "ResultType",
+ table: "UnitTest",
+ type: "int",
+ nullable: true,
+ defaultValue: 0,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "UnitTest",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "FloatSeparators",
+ table: "UnitTest",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "DecimalPlaces",
+ table: "UnitTest",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "DateTimeFormat",
+ table: "UnitTest",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "Expected Result",
+ table: "UnitTest",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AddColumn(
+ name: "CreatedBy",
+ table: "UnitTest",
+ type: "int",
+ nullable: true,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "CreatedOn",
+ table: "UnitTest",
+ type: "datetime2",
+ nullable: true,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "ModifiedBy",
+ table: "UnitTest",
+ type: "int",
+ nullable: true,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "ModifiedOn",
+ table: "UnitTest",
+ type: "datetime2",
+ nullable: true,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "Tenant",
+ type: "nvarchar(100)",
+ maxLength: 100,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(100)",
+ oldUnicode: false,
+ oldMaxLength: 100);
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "TabularModel",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "Ms Id",
+ table: "TabularModel",
+ type: "uniqueidentifier",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "ResultType",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AddColumn(
+ name: "Id",
+ table: "ResultType",
+ type: "int",
+ nullable: false,
+ defaultValue: 0)
+ .Annotation("SqlServer:Identity", "1, 1");
+
+ migrationBuilder.AlterColumn(
+ name: "TimeStamp",
+ table: "TestRunCollection",
+ type: "datetime2",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(max)",
+ oldUnicode: false);
+
+ migrationBuilder.AddColumn(
+ name: "CreatedBy",
+ table: "TestRunCollection",
+ type: "int",
+ nullable: true,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "CreatedOn",
+ table: "TestRunCollection",
+ type: "datetime2",
+ nullable: true,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "ModifiedBy",
+ table: "TestRunCollection",
+ type: "int",
+ nullable: true,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "ModifiedOn",
+ table: "TestRunCollection",
+ type: "datetime2",
+ nullable: true,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AlterColumn(
+ name: "TimeStamp",
+ table: "TestRun",
+ type: "datetime2",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(max)",
+ oldUnicode: false);
+
+ migrationBuilder.AlterColumn(
+ name: "TestRun",
+ table: "TestRun",
+ type: "int",
+ nullable: false,
+ defaultValue: 0,
+ oldClrType: typeof(int),
+ oldType: "int",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "LastRun",
+ table: "TestRun",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "WasPassed",
+ table: "TestRun",
+ type: "bit",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "Expected Result",
+ table: "TestRun",
+ type: "nvarchar(255)",
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "varchar(255)",
+ oldUnicode: false,
+ oldMaxLength: 255);
+
+ migrationBuilder.AddColumn(
+ name: "CreatedBy",
+ table: "TestRun",
+ type: "int",
+ nullable: true,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "CreatedOn",
+ table: "TestRun",
+ type: "datetime2",
+ nullable: true,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn(
+ name: "ModifiedBy",
+ table: "TestRun",
+ type: "int",
+ nullable: true,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "ModifiedOn",
+ table: "TestRun",
+ type: "datetime2",
+ nullable: true,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_ResultType",
+ table: "ResultType",
+ column: "Id");
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_TestRunCollection",
+ table: "TestRunCollection",
+ column: "Id");
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_TestRun",
+ table: "TestRun",
+ column: "Id");
+
+ migrationBuilder.InsertData(
+ table: "ResultType",
+ columns: new[] { "Id", "Name" },
+ values: new object[,]
+ {
+ { 1, "Date" },
+ { 2, "Float" },
+ { 3, "Percentage" },
+ { 4, "String" }
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Workspace_TenantNavigationId",
+ table: "Workspace",
+ column: "TenantNavigationId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UserStory_CreatedBy",
+ table: "UserStory",
+ column: "CreatedBy");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UserStory_ModifiedBy",
+ table: "UserStory",
+ column: "ModifiedBy");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UnitTest_CreatedBy",
+ table: "UnitTest",
+ column: "CreatedBy");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UnitTest_ModifiedBy",
+ table: "UnitTest",
+ column: "ModifiedBy");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TestRunCollection_CreatedBy",
+ table: "TestRunCollection",
+ column: "CreatedBy");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TestRunCollection_ModifiedBy",
+ table: "TestRunCollection",
+ column: "ModifiedBy");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TestRun_CreatedBy",
+ table: "TestRun",
+ column: "CreatedBy");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TestRun_ModifiedBy",
+ table: "TestRun",
+ column: "ModifiedBy");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_TestRun_Created_By",
+ table: "TestRun",
+ column: "CreatedBy",
+ principalTable: "User",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_TestRun_Modified_By",
+ table: "TestRun",
+ column: "ModifiedBy",
+ principalTable: "User",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_TestRun_TestRunCollection_TestRun",
+ table: "TestRun",
+ column: "TestRun",
+ principalTable: "TestRunCollection",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_TestRun_UnitTest_UnitTest",
+ table: "TestRun",
+ column: "UnitTest",
+ principalTable: "UnitTest",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_TestRunCollection_Created_By",
+ table: "TestRunCollection",
+ column: "CreatedBy",
+ principalTable: "User",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_TestRunCollection_Modified_By",
+ table: "TestRunCollection",
+ column: "ModifiedBy",
+ principalTable: "User",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_UnitTest_Created_By",
+ table: "UnitTest",
+ column: "CreatedBy",
+ principalTable: "User",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_UnitTest_Modified_By",
+ table: "UnitTest",
+ column: "ModifiedBy",
+ principalTable: "User",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_UnitTest_ResultType_ResultType",
+ table: "UnitTest",
+ column: "ResultType",
+ principalTable: "ResultType",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_UserStory_Created_By",
+ table: "UserStory",
+ column: "CreatedBy",
+ principalTable: "User",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_UserStory_Modified_By",
+ table: "UserStory",
+ column: "ModifiedBy",
+ principalTable: "User",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Workspace_Tenant_TenantNavigationId",
+ table: "Workspace",
+ column: "TenantNavigationId",
+ principalTable: "Tenant",
+ principalColumn: "Id");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_TestRun_Created_By",
+ table: "TestRun");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_TestRun_Modified_By",
+ table: "TestRun");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_TestRun_TestRunCollection_TestRun",
+ table: "TestRun");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_TestRun_UnitTest_UnitTest",
+ table: "TestRun");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_TestRunCollection_Created_By",
+ table: "TestRunCollection");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_TestRunCollection_Modified_By",
+ table: "TestRunCollection");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_UnitTest_Created_By",
+ table: "UnitTest");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_UnitTest_Modified_By",
+ table: "UnitTest");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_UnitTest_ResultType_ResultType",
+ table: "UnitTest");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_UserStory_Created_By",
+ table: "UserStory");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_UserStory_Modified_By",
+ table: "UserStory");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Workspace_Tenant_TenantNavigationId",
+ table: "Workspace");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Workspace_TenantNavigationId",
+ table: "Workspace");
+
+ migrationBuilder.DropIndex(
+ name: "IX_UserStory_CreatedBy",
+ table: "UserStory");
+
+ migrationBuilder.DropIndex(
+ name: "IX_UserStory_ModifiedBy",
+ table: "UserStory");
+
+ migrationBuilder.DropIndex(
+ name: "IX_UnitTest_CreatedBy",
+ table: "UnitTest");
+
+ migrationBuilder.DropIndex(
+ name: "IX_UnitTest_ModifiedBy",
+ table: "UnitTest");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_ResultType",
+ table: "ResultType");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_TestRunCollection",
+ table: "TestRunCollection");
+
+ migrationBuilder.DropIndex(
+ name: "IX_TestRunCollection_CreatedBy",
+ table: "TestRunCollection");
+
+ migrationBuilder.DropIndex(
+ name: "IX_TestRunCollection_ModifiedBy",
+ table: "TestRunCollection");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_TestRun",
+ table: "TestRun");
+
+ migrationBuilder.DropIndex(
+ name: "IX_TestRun_CreatedBy",
+ table: "TestRun");
+
+ migrationBuilder.DropIndex(
+ name: "IX_TestRun_ModifiedBy",
+ table: "TestRun");
+
+ migrationBuilder.DropColumn(
+ name: "TenantNavigationId",
+ table: "Workspace");
+
+ migrationBuilder.DropColumn(
+ name: "CreatedBy",
+ table: "UserStory");
+
+ migrationBuilder.DropColumn(
+ name: "CreatedOn",
+ table: "UserStory");
+
+ migrationBuilder.DropColumn(
+ name: "ModifiedBy",
+ table: "UserStory");
+
+ migrationBuilder.DropColumn(
+ name: "ModifiedOn",
+ table: "UserStory");
+
+ migrationBuilder.DropColumn(
+ name: "CreatedBy",
+ table: "UnitTest");
+
+ migrationBuilder.DropColumn(
+ name: "CreatedOn",
+ table: "UnitTest");
+
+ migrationBuilder.DropColumn(
+ name: "ModifiedBy",
+ table: "UnitTest");
+
+ migrationBuilder.DropColumn(
+ name: "ModifiedOn",
+ table: "UnitTest");
+
+ migrationBuilder.DropColumn(
+ name: "Id",
+ table: "ResultType");
+
+ migrationBuilder.DropColumn(
+ name: "CreatedBy",
+ table: "TestRunCollection");
+
+ migrationBuilder.DropColumn(
+ name: "CreatedOn",
+ table: "TestRunCollection");
+
+ migrationBuilder.DropColumn(
+ name: "ModifiedBy",
+ table: "TestRunCollection");
+
+ migrationBuilder.DropColumn(
+ name: "ModifiedOn",
+ table: "TestRunCollection");
+
+ migrationBuilder.DropColumn(
+ name: "CreatedBy",
+ table: "TestRun");
+
+ migrationBuilder.DropColumn(
+ name: "CreatedOn",
+ table: "TestRun");
+
+ migrationBuilder.DropColumn(
+ name: "ModifiedBy",
+ table: "TestRun");
+
+ migrationBuilder.DropColumn(
+ name: "ModifiedOn",
+ table: "TestRun");
+
+ migrationBuilder.RenameTable(
+ name: "TestRunCollection",
+ newName: "TestRuns");
+
+ migrationBuilder.RenameTable(
+ name: "TestRun",
+ newName: "History");
+
+ migrationBuilder.RenameColumn(
+ name: "Ms Id",
+ table: "Workspace",
+ newName: "WorkspacePbId");
+
+ migrationBuilder.RenameColumn(
+ name: "Description",
+ table: "UserStory",
+ newName: "Beschreibung");
+
+ migrationBuilder.RenameColumn(
+ name: "Expected Result",
+ table: "UnitTest",
+ newName: "ExpectedResult");
+
+ migrationBuilder.RenameColumn(
+ name: "Ms Id",
+ table: "TabularModel",
+ newName: "DatasetPbId");
+
+ migrationBuilder.RenameColumn(
+ name: "WasPassed",
+ table: "History",
+ newName: "Result");
+
+ migrationBuilder.RenameColumn(
+ name: "Expected Result",
+ table: "History",
+ newName: "ExpectedRun");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_TestRun_UnitTest",
+ table: "History",
+ newName: "IX_History_UnitTest");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_TestRun_TestRun",
+ table: "History",
+ newName: "IX_History_TestRun");
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "Workspace",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "WorkspacePbId",
+ table: "Workspace",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(Guid),
+ oldType: "uniqueidentifier");
+
+ migrationBuilder.AlterColumn(
+ name: "Beschreibung",
+ table: "UserStory",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "Lastname",
+ table: "User",
+ type: "varchar(100)",
+ unicode: false,
+ maxLength: 100,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "Firstname",
+ table: "User",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "Email",
+ table: "User",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "ResultType",
+ table: "UnitTest",
+ type: "varchar(255)",
+ nullable: true,
+ oldClrType: typeof(int),
+ oldType: "int");
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "UnitTest",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "FloatSeparators",
+ table: "UnitTest",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "DecimalPlaces",
+ table: "UnitTest",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "DateTimeFormat",
+ table: "UnitTest",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "ExpectedResult",
+ table: "UnitTest",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255);
+
+ migrationBuilder.AddColumn(
+ name: "LastResult",
+ table: "UnitTest",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "LastRun",
+ table: "UnitTest",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: true,
+ defaultValue: "Error");
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "Tenant",
+ type: "varchar(100)",
+ unicode: false,
+ maxLength: 100,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(100)",
+ oldMaxLength: 100);
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "TabularModel",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "DatasetPbId",
+ table: "TabularModel",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(Guid),
+ oldType: "uniqueidentifier");
+
+ migrationBuilder.AlterColumn(
+ name: "Name",
+ table: "ResultType",
+ type: "varchar(255)",
+ unicode: false,
+ maxLength: 255,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(255)",
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn