public async Task Update_Api_Resource_Server_validator(UpdateApiResourceDto model, bool isvalid) { using (var ctx = await TestDbContext.Create(nameof(Update_Api_Resource_Server_validator))) { ApiResource entity = new ApiResource { Address = "z", HttpMethod = HttpMethods.GET, Title = "z" }; ApiResource entity2 = new ApiResource { Address = "zx", HttpMethod = HttpMethods.GET, Title = "zx" }; entity.Id = Update_Api_Resource_validatorTestData.validGuid; entity2.Id = Update_Api_Resource_validatorTestData.validGuid2; ctx.ApiResources.Add(entity); ctx.ApiResources.Add(entity2); await ctx.SaveChangesAsync(); var vaidator = new ServerSideValidator(ctx); var validation = vaidator.Validate(new UpdateApiResource(model)); _output.WriteLine(string.Join(",\n", validation.Errors.Select(x => x.ErrorMessage))); Assert.Equal(isvalid, validation.IsValid); } }
public async Task Add_Api_Resource_Server_validator(AddApiResourceDto model, bool isvalid) { using (var ctx = await TestDbContext.Create(nameof(Add_Api_Resource_Server_validator))) { ApiResource entity = new ApiResource { Address = "z", HttpMethod = DotNetAccessControl.domain.enums.HttpMethods.GET, Title = "z" }; ctx.ApiResources.Add(entity); await ctx.SaveChangesAsync(); var vaidator = new ServerSideValidator(ctx); Assert.Equal(isvalid, vaidator.Validate(new AddApiResource(model)).IsValid); } }