Пример #1
0
        public void Constructor_Should_Construct_User_Properly()
        {
            //Act
            var user = _builder.Build();

            //Assert
            Assert.Equal(_builder.Id, user.Id.DbId);
            Assert.Equal(_builder.FullName, user.FullName);
        }
        public void Constructor_Should_Construct_User_Properly()
        {
            //Arrange
            var userBuilder = new UserTestBuilder();

            //Act
            var user = userBuilder.Build();

            //Assert
            user.Id.Should().Be(userBuilder.UserId);
            user.Username.Should().Be(userBuilder.Username);
            user.Password.Should().Be(userBuilder.Password);
            user.FullName.Should().Be(userBuilder.Firstname);
            user.Lastname.Should().Be(userBuilder.Lastname);
        }
        public async Task GetUsers_ReturnsBadRequestObjectResponse_GivenFieldParameterWithNoId()
        {
            //Arrange
            string mediaType = "application/json+hateoas";
            var    users     = _builder.Build(2);
            var    pagedList = PagedList <User> .Create(users,
                                                        resourceParameters.Page, resourceParameters.PageSize);

            resourceParameters.Fields = "UserName";

            _mockUserService
            .Setup(u => u.FindUsers(resourceParameters))
            .ReturnsAsync(pagedList);

            //Act
            var response = await _controller.GetUsers(resourceParameters, mediaType);

            //Assert
            Assert.IsType <BadRequestObjectResult>(response);
        }