public async void Should_return_BadRequest_when_Id_is_zero()
            {
                //Arrange
                var            unexistingUserId = 0;
                List <Address> address          = new List <Address>()
                {
                    AddressData
                };

                var key             = "Address_StatusCode_400_BadRequest";
                var localizedString = new LocalizedString(key, "Bad Request");

                LocalizerMock
                .Setup(_ => _[key])
                .Returns(localizedString);

                //Act
                var result = await ControllerUnderTest.Update(unexistingUserId, address);

                //Assert
                Assert.IsType <BadRequestObjectResult>(result);
            }
Esempio n. 2
0
            public async void Should_return_NotFoundResult_when_UserNotFoundException_is_thrown()
            {
                // Arrange
                var    unexistingUserId = 0;
                string key             = "Me_StatusCode_404_NotFound";
                var    localizedString = new LocalizedString(key, "Not Found");

                UserServiceMock
                .Setup(x => x.ReadOneAsync(unexistingUserId))
                .ThrowsAsync(new Exception(unexistingUserId.ToString()));

                LocalizerMock
                .Setup(_ => _[key]).Returns(localizedString);

                // set header values

                ControllerUnderTest.ControllerContext.HttpContext.Request.Headers.Add("id", unexistingUserId.ToString());

                // ActA
                var result = await ControllerUnderTest.GetUser();

                // Assert
                Assert.IsType <NotFoundObjectResult>(result);
            }