Example #1
0
        public async Task ShouldReturn_AllCategories()
        {
            await nieuweStroomPocDbContext.Categories.AddRangeAsync(new Category[] {
                new Category()
                {
                    Description = "Category1"
                },
                new Category()
                {
                    Description = "Category2"
                }
            });

            await nieuweStroomPocDbContext.SaveChangesAsync();

            var response = await request.Get("/api/categories");

            var body = await response.BodyAs <KeyValuePairResource[]>();


            response.StatusCode.Should().Be(HttpStatusCode.OK);
            body.Length.Should().Be(2);
            body.Should().ContainSingle(gn => gn.Description == "Category1");
            body.Should().ContainSingle(gn => gn.Description == "Category2");
        }
Example #2
0
        public async Task ShouldReturn_Roles_ById()
        {
            var role = new Role()
            {
                Description = "Role 1"
            };
            await nieuweStroomPocDbContext.Roles.AddAsync(role);

            await nieuweStroomPocDbContext.SaveChangesAsync();

            var response = await request.Get($"/api/roles/{role.Id}");

            var body = await response.BodyAs <KeyValuePairResource>();

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            body.Description.Should().Be(role.Description);
        }
Example #3
0
        public async Task ShouldReturn_Cateogory_ById()
        {
            var category = new Category()
            {
                Description = "Category1"
            };
            await nieuweStroomPocDbContext.Categories.AddAsync(category);

            await nieuweStroomPocDbContext.SaveChangesAsync();

            var response = await request.Get($"/api/categories/{category.Id}");

            var body = await response.BodyAs <KeyValuePairResource>();

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            body.Description.Should().Be(category.Description);
        }
        public async Task ShouldReturns_400_IfEmailAlreadyRegistered()
        {
            await nieuweStroomPocDbContext.AddAsync(new User()
            {
                JoinDate = DateTime.Now,
                Name     = userResource.Name,
                Lastname = userResource.Lastname,
                Email    = userResource.Email,
                Password = new byte[64],
                Salt     = new byte[128]
            });

            await nieuweStroomPocDbContext.SaveChangesAsync();

            var res = await Exec();

            var body = await res.BodyAs <ValidationErrorResource>();

            body.Errors.Should().ContainKey("Email");
            res.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
Example #5
0
 public Task <int> SaveAsync()
 {
     return(nieuweStroomPocDbContext.SaveChangesAsync());
 }