public async Task Can_Add_ApiResource() { using (var ctx = await TestDbContext.Create(nameof(Can_Add_ApiResource))) { var mapper = new MapperConfiguration(cfg => cfg.AddProfile(new MappingProfile())); var model = new AddApiResourceDto( "http://abc", DotNetAccessControl.domain.enums.HttpMethods.GET, "Some Title" ); var request = new AddApiResource(model); var response = await new AddApiResourceHandler(ctx, mapper.CreateMapper()).Handle(request, CancellationToken.None); Assert.True(await ctx.ApiResources.AnyAsync(x => x.Id == response)); } }
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); } }
public void Add_Api_Resource_Client_validator(AddApiResourceDto model, bool isvalid) { var validator = new ClientSideValidator(); Assert.Equal(isvalid, validator.Validate(model).IsValid); }