Skip to content

Commit

Permalink
Refactor mock data
Browse files Browse the repository at this point in the history
  • Loading branch information
kjetilhau committed Nov 4, 2024
1 parent 092b022 commit 3f1c0ef
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

namespace Equinor.ProjectExecutionPortal.Tests.WebApi.Data
{
internal class ContextTypeData
internal static class ContextTypeData
{
public class InitialDbSeedData
public static class InitialDbSeedData
{
public static ContextType ContextType1 = new(ValidContextTypes.ProjectMasterContextTypeKey);
public static ContextType ContextType2 = new(ValidContextTypes.FacilityContextTypeKey);
public static readonly ContextType ContextType1 = new(ValidContextTypes.ProjectMasterContextTypeKey);
public static readonly ContextType ContextType2 = new(ValidContextTypes.FacilityContextTypeKey);
}

public class ValidContextTypes
public static class ValidContextTypes
{
public static string ProjectMasterContextTypeKey = "ProjectMaster";
public static string FacilityContextTypeKey = "Facility";
public static string ContractContextTypeKey = "Contract";
public const string ProjectMasterContextTypeKey = "ProjectMaster";
public const string FacilityContextTypeKey = "Facility";
public const string ContractContextTypeKey = "Contract";
}

public class InvalidContextTypes
public static class InvalidContextTypes
{
public static string InvalidContextTypeKey = "SuperContext";
public const string InvalidContextTypeKey = "SuperContext";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Equinor.ProjectExecutionPortal.Tests.WebApi.Data
{
internal class FusionAppApiData
internal static class FusionAppApiData
{
public static App MeetingsFusion => new()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Equinor.ProjectExecutionPortal.Tests.WebApi.Data
{
internal class FusionContextApiData
internal static class FusionContextApiData
{
public static string JcaContextExternalId = "fc5ffcbc-392f-4d7e-bb14-79a006579337";
public const string JcaContextExternalId = "fc5ffcbc-392f-4d7e-bb14-79a006579337";
public static Guid JcaContextId = new("94dd5f4d-17f1-4312-bf75-ad75f4d9572c");
public static string OgpContextExternalId = "91dd6653-a364-40c7-af26-7af516d66c42";
public const string OgpContextExternalId = "91dd6653-a364-40c7-af26-7af516d66c42";
public static Guid OgpContextId = new("ce31b83a-b6cd-4267-89f3-db308edf721e");
public static string MongstadContextExternalId = "09206ca3-02ac-4c65-adbf-caa7b66364ea";
public const string MongstadContextExternalId = "09206ca3-02ac-4c65-adbf-caa7b66364ea";
public static Guid MongstadContextId = new("4CB78175-46CF-41A3-58DB-08DC74C80D40");
public static string InvalidContextExternalId = "11111111-1111-1111-1111-111111111111";
public const string InvalidContextExternalId = "11111111-1111-1111-1111-111111111111";
public static Guid InvalidContextId = new("11111111-1111-1111-1111-111111111111");

public static FusionContext JcaFusionContext => new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Equinor.ProjectExecutionPortal.Tests.WebApi.Data
{
internal class OnboardedAppData
internal static class OnboardedAppData
{
public class InitialDbSeedData
public static class InitialDbSeedData
{
public static OnboardedApp MeetingsApp = new("meetings");
public static OnboardedApp ReviewsApp = new("reviews");
public static OnboardedApp TasksApp = new("tasks");
public static OnboardedApp OrgChartApp = new("one-equinor");
public static OnboardedApp HandoverGardenApp = new("handover-garden");
public static OnboardedApp WorkOrderGardenApp = new("workorder-garden");
public static readonly OnboardedApp MeetingsApp = new("meetings");
public static readonly OnboardedApp ReviewsApp = new("reviews");
public static readonly OnboardedApp TasksApp = new("tasks");
public static readonly OnboardedApp OrgChartApp = new("one-equinor");
public static readonly OnboardedApp HandoverGardenApp = new("handover-garden");
public static readonly OnboardedApp WorkOrderGardenApp = new("workorder-garden");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Equinor.ProjectExecutionPortal.Tests.WebApi.Data
{
internal class OnboardedContextData
internal static class OnboardedContextData
{
public class InitialDbSeedData
public static class InitialDbSeedData
{
public static OnboardedContext JcaContext = new(FusionContextApiData.JcaContextExternalId, ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey, "desc");
public static OnboardedContext OgpContext = new(FusionContextApiData.OgpContextExternalId, ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey, "desc");
public static readonly OnboardedContext JcaContext = new(FusionContextApiData.JcaContextExternalId, ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey, "desc");
public static readonly OnboardedContext OgpContext = new(FusionContextApiData.OgpContextExternalId, ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey, "desc");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Equinor.ProjectExecutionPortal.Tests.WebApi.Data
{
internal class PortalConfigurationData
internal static class PortalConfigurationData
{
public class InitialDbSeedData
public static class InitialDbSeedData
{
public static PortalConfiguration GenericPortalConfiguration = new(
public static readonly PortalConfiguration GenericPortalConfiguration = new(
"routerConfig",
"extensionConfig",
"environmentConfig"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Equinor.ProjectExecutionPortal.Tests.WebApi.Data
{
internal class PortalData
internal static class PortalData
{
public class InitialDbSeedData
public static class InitialDbSeedData
{
public static Portal PortfolioManagement = new(
public static readonly Portal PortfolioManagement = new(
"portfolio-management",
"Portfolio Management",
"< DG 3",
Expand All @@ -15,7 +15,7 @@ public class InitialDbSeedData
"<svg></svg>"
);

public static Portal ProjectExecution = new("project-execution",
public static readonly Portal ProjectExecution = new("project-execution",
"Project Execution",
"DG 3 - DG 4",
"Go to this phase to work with projects that are beyond DG3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task Create_Portal_AsAdministratorUser_ShouldReturnOk()
ShortName = "Created short name",
Subtext = "Created subtext",
Icon = "Created icon",
ContextTypes = new List<string> { ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey }
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
};

// Act
Expand All @@ -103,7 +103,15 @@ public async Task Create_Portal_AsAdministratorUser_ShouldReturnOk()
public async Task Create_Portal_AsAuthenticatedUser_ShouldReturnForbidden()
{
// Arrange
var payload = new ApiCreatePortalRequest();
var payload = new ApiCreatePortalRequest
{
Name = "Created portal name",
Description = "Created description",
ShortName = "Created short name",
Subtext = "Created subtext",
Icon = "Created icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
};

// Act
var response = await CreatePortal(UserType.Authenticated, payload);
Expand All @@ -116,7 +124,15 @@ public async Task Create_Portal_AsAuthenticatedUser_ShouldReturnForbidden()
public async Task Create_Portal_AsAnonymousUser_ShouldReturnUnauthorized()
{
// Arrange
var payload = new ApiCreatePortalRequest();
var payload = new ApiCreatePortalRequest
{
Name = "Created portal name",
Description = "Created description",
ShortName = "Created short name",
Subtext = "Created subtext",
Icon = "Created icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
};

// Act
var response = await CreatePortal(UserType.Anonymous, payload);
Expand All @@ -139,7 +155,7 @@ public async Task Update_Portal_AsAdministratorUser_ShouldReturnOk()
ShortName = "Updated short name",
Subtext = "Updated subtext",
Icon = "Updated icon",
ContextTypes = new List<string> { ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey }
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
};

// Act
Expand All @@ -162,7 +178,15 @@ public async Task Update_Portal_AsAdministratorUser_ShouldReturnOk()
public async Task Update_Portal_AsAuthenticatedUser_ShouldReturnForbidden()
{
// Arrange
var payload = new ApiUpdatePortalRequest();
var payload = new ApiUpdatePortalRequest
{
Name = "Updated portal name",
Description = "Updated description",
ShortName = "Updated short name",
Subtext = "Updated subtext",
Icon = "Updated icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
};

// Act
var response = await UpdatePortal(UserType.Authenticated, payload, Guid.NewGuid());
Expand All @@ -175,7 +199,15 @@ public async Task Update_Portal_AsAuthenticatedUser_ShouldReturnForbidden()
public async Task Update_Portal_AsAnonymousUser_ShouldReturnUnauthorized()
{
// Arrange
var payload = new ApiUpdatePortalRequest();
var payload = new ApiUpdatePortalRequest
{
Name = "Updated portal name",
Description = "Updated description",
ShortName = "Updated short name",
Subtext = "Updated subtext",
Icon = "Updated icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
};

// Act
var response = await UpdatePortal(UserType.Anonymous, payload, Guid.NewGuid());
Expand Down Expand Up @@ -442,7 +474,7 @@ public async Task Delete_Portal_AsAdministrator_ShouldReturnOk()
ShortName = "Created short name",
Subtext = "Created subtext",
Icon = "Created icon",
ContextTypes = new List<string> { "ProjectMaster" }
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
};

await CreatePortal(UserType.Administrator, payload);
Expand Down

0 comments on commit 3f1c0ef

Please sign in to comment.