Skip to content

Commit

Permalink
able to compile all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkoSekulic committed Jan 16, 2025
1 parent 7704e99 commit d80590b
Show file tree
Hide file tree
Showing 107 changed files with 764 additions and 642 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static DeploymentDbModel MapToDbModel(DeploymentEntity deploymentEntity)
EnvName = deploymentEntity.EnvName,
Buildresult = deploymentEntity.Build.Result.ToEnumMemberAttributeValue(),
Created = deploymentEntity.Created.ToUniversalTime(),
CreatedBy = deploymentEntity.CreatedBy,
Entity = JsonSerializer.Serialize(deploymentEntity, s_jsonOptions),
Build = BuildMapper.MapToDbModel(deploymentEntity.Build, BuildType.Deployment),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,4 @@ protected TTestType KeywordShouldNotBeNull()
return this as TTestType;
}

// protected TTestType KeywordShouldBeNull()
// {
// Assert.Null(Keyword);
// return this as TTestType;
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Task Analyze_SimpleContent_Extension(string path)
[InlineData(@"Model/JsonSchema/Seres/SeresSimpleTypeRestrictions.json")]
public Task Analyze_SimpleType_Restriction(string path)
{
JsonSchemaKeywords.RegisterXsdKeywords();
JsonSchemaKeywords.RegisterXsdKeywords();

var schema = SharedResourcesHelper.LoadJsonSchemaTestData(path);
var analyzer = new SeresJsonSchemaAnalyzer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public async Task AuthStatus_Should_ReturnFalse_IfNotAuthenticated()
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, VersionPrefix);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

AuthStatus authStatus = await response.Content.ReadAsAsync<AuthStatus>();
authStatus.IsLoggedIn.Should().BeFalse();
Assert.False(authStatus.IsLoggedIn);
}

[Fact]
Expand All @@ -74,9 +74,9 @@ public async Task AuthStatus_Should_ReturnTrue_IfAuthenticated()
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, VersionPrefix);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

AuthStatus authStatus = await response.Content.ReadAsAsync<AuthStatus>();
authStatus.IsLoggedIn.Should().BeTrue();
Assert.True(authStatus.IsLoggedIn);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Designer.Tests.Controllers.ApiTests;
using Designer.Tests.Utils;
using Microsoft.AspNetCore.Mvc.Testing;
using SharedResources.Tests;
using Xunit;

namespace Designer.Tests.Controllers.AppDevelopmentController
Expand Down Expand Up @@ -44,14 +45,14 @@ public async Task AddLayoutSets_NewSet_ReturnsOk(string org, string app, string
};

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

LayoutSets layoutSetsAfter = await GetLayoutSetsFile(org, targetRepository, developer);

layoutSetsBefore.Schema.Should().NotBeNull();
Assert.NotNull(layoutSetsBefore.Schema);
Assert.False(layoutSetsBefore.Sets.Exists(set => set.Id == newLayoutSetConfig.Id));
layoutSetsBefore.Sets.Count.Should().Be(layoutSetsAfter.Sets.Count - 1);
layoutSetsAfter.Schema.Should().NotBeNull();
Assert.Equal(layoutSetsAfter.Sets.Count - 1, layoutSetsBefore.Sets.Count);
Assert.NotNull(layoutSetsAfter.Schema);
Assert.True(layoutSetsAfter.Sets.Exists(set => set.Id == newLayoutSetConfig.Id));
}

Expand All @@ -74,7 +75,7 @@ public async Task AddLayoutSet_NewLayoutSetIdExistsBefore_ReturnsOKButWithConfli
};

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
string responseContent = await response.Content.ReadAsStringAsync();
Dictionary<string, string> responseMessage = JsonSerializer.Deserialize<Dictionary<string, string>>(responseContent);
Assert.Equal($"Layout set name, {layoutSetId}, already exists.", responseMessage["infoMessage"]);
Expand All @@ -100,7 +101,7 @@ public async Task AddLayoutSet_NewLayoutSetTaskIdExistsBefore_ReturnsOKButWithCo
};

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
string responseContent = await response.Content.ReadAsStringAsync();
Dictionary<string, string> responseMessage = JsonSerializer.Deserialize<Dictionary<string, string>>(responseContent);
Assert.Equal($"Layout set with task, {existingTaskId}, already exists.", responseMessage["infoMessage"]);
Expand All @@ -125,7 +126,7 @@ public async Task AddLayoutSet_NewLayoutSetIdIsEmpty_ReturnsBadRequest(string or
};

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
}

[Theory]
Expand All @@ -147,7 +148,7 @@ public async Task AddLayoutSet_TaskTypeIsNull_AddsLayoutSetAndReturnsOk(string o
};

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Theory]
Expand All @@ -169,7 +170,7 @@ public async Task AddLayoutSet_TaskTypeIsPayment_AddsLayoutSetWithPaymentCompone
};

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

JsonNode initialLayout = await GetLayoutFile(org, targetRepository, developer, layoutSetId);

Expand All @@ -181,8 +182,9 @@ public async Task AddLayoutSet_TaskTypeIsPayment_AddsLayoutSetWithPaymentCompone
};

JsonArray layout = initialLayout["data"]["layout"] as JsonArray;
layout.Count.Should().Be(1);
initialLayout["data"]["layout"][0].Should().BeEquivalentTo(defaultComponent, options => options.RespectingRuntimeTypes().IgnoringCyclicReferences());

Assert.Single(layout);
Assert.True(JsonUtils.DeepEquals(defaultComponent.ToJsonString(), initialLayout["data"]["layout"][0].ToJsonString()));
}

[Theory]
Expand All @@ -204,7 +206,7 @@ public async Task AddLayoutSet_AppWithoutLayoutSets_ReturnsNotFound(string org,
};

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}

private async Task<LayoutSets> GetLayoutSetsFile(string org, string app, string developer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public async Task DeleteFormLayout_ShouldDeleteLayoutFile_AndReturnOk(string org
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

string relativePath = string.IsNullOrEmpty(layoutSetName)
? $"App/ui/layouts/{layoutName}.json"
: $"App/ui/{layoutSetName}/layouts/{layoutName}.json";
string layoutFilePath = Path.Combine(TestRepoPath, relativePath);
File.Exists(layoutFilePath).Should().BeFalse();
Assert.False(File.Exists(layoutFilePath));
}

[Theory]
Expand All @@ -52,7 +52,7 @@ public async Task DeleteFormLayout_NonExistingFile_Should_AndReturnNotFound(stri
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public async Task DeleteLayoutSet_SetWithoutDataTypeConnection_ReturnsOk(string
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

LayoutSets layoutSetsAfter = await GetLayoutSetsFile(org, targetRepository, developer);

Assert.True(layoutSetsBefore.Sets.Exists(set => set.Id == layoutSetToDeleteId));
layoutSetsAfter.Sets.Should().HaveCount(layoutSetsBefore.Sets.Count - 1);
Assert.Equal(layoutSetsBefore.Sets.Count - 1, layoutSetsAfter.Sets.Count);
Assert.False(layoutSetsAfter.Sets.Exists(set => set.Id == layoutSetToDeleteId));
}

Expand All @@ -62,16 +62,15 @@ public async Task DeleteLayoutSet_SetWithDataTypeConnection_ReturnsOk(string org
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

LayoutSets layoutSetsAfter = await GetLayoutSetsFile(org, targetRepository, developer);
Application appMetadataAfter = await GetApplicationMetadataFile(org, targetRepository, developer);

appMetadataBefore.DataTypes.Find(dataType => dataType.Id == connectedDataType).TaskId.Should()
.Be(connectedTaskId);
Assert.Equal(connectedTaskId, appMetadataBefore.DataTypes.Find(dataType => dataType.Id == connectedDataType).TaskId);
Assert.True(layoutSetsBefore.Sets.Exists(set => set.Id == layoutSetToDeleteId));
layoutSetsAfter.Sets.Should().HaveCount(layoutSetsBefore.Sets.Count - 1);
appMetadataAfter.DataTypes.Find(dataType => dataType.Id == connectedDataType).TaskId.Should().BeNull();
Assert.Equal(layoutSetsBefore.Sets.Count - 1, layoutSetsAfter.Sets.Count);
Assert.Null(appMetadataAfter.DataTypes.Find(dataType => dataType.Id == connectedDataType).TaskId);
Assert.False(layoutSetsAfter.Sets.Exists(set => set.Id == layoutSetToDeleteId));
}

Expand All @@ -90,7 +89,7 @@ public async Task DeleteLayoutSet_DeletesRelatedLayoutSetFolder_ReturnsOk(string
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

Assert.False(LayoutSetFolderExists(org, targetRepository, developer, layoutSetToDeleteId));
}
Expand All @@ -110,7 +109,7 @@ public async Task DeleteLayoutSet_IdNotFound_ReturnsUnAlteredLayoutSets(string o
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

string responseContent = await response.Content.ReadAsStringAsync();

Expand All @@ -130,7 +129,7 @@ public async Task DeleteLayoutSet_AppWithoutLayoutSets_ReturnsNotFound(string or
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}

[Theory]
Expand All @@ -146,17 +145,20 @@ public async Task DeleteLayoutSet_RemovesComponentsReferencingLayoutSet(string o
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, url);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK, await response.Content.ReadAsStringAsync());
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

JsonNode formLayout = (await GetFormLayouts(org, targetRepository, developer, layoutSetWithRef))[layoutSetFile];
JsonArray layout = formLayout["data"]?["layout"] as JsonArray;

layout.Should().NotBeNull();
layout
bool componentsReferencingDeletedLayoutSet = layout
.Where(jsonNode => jsonNode["layoutSet"] != null)
.Should()
.NotContain(jsonNode => jsonNode["layoutSet"].GetValue<string>() == deletedComponentId,
$"No components should reference the deleted layout set {deletedComponentId}");
.Any(jsonNode => jsonNode["layoutSet"].GetValue<string>() == deletedComponentId);

Assert.False(componentsReferencingDeletedLayoutSet, $"No components should reference the deleted layout set {deletedComponentId}");

Assert.NotNull(layout);


}

private async Task<LayoutSets> GetLayoutSetsFile(string org, string app, string developer)
Expand Down
Loading

0 comments on commit d80590b

Please sign in to comment.