コード例 #1
0
        public void Post_GoodRequest_ReturnsStatusOKWithResults()
        {
            // Arrange
            User expectedUser = new User()
            {
                Id          = 1,
                Username    = "******",
                Displayname = "พลอย"
            };
            ResponseMessage expectedResponseMessage = new ResponseMessage();

            expectedResponseMessage.Status  = "OK";
            expectedResponseMessage.Results = expectedUser;

            StubSuccessAuthenticationService service = new StubSuccessAuthenticationService();
            LoginController controller = new LoginController(service);

            // Act
            ResponseMessage actualResponse = controller.Post(goodRequest);
            User            actualUser     = actualResponse.Results;

            // Assert
            Assert.IsType <ResponseMessage>(actualResponse);
            Assert.Equal(expectedResponseMessage.Status, actualResponse.Status);
            Assert.IsType <User>(actualUser);
            Assert.Equal(expectedUser.Id, actualUser.Id);
            Assert.Equal(expectedUser.Username, actualUser.Username);
            Assert.Equal(expectedUser.Displayname, actualUser.Displayname);
        }
コード例 #2
0
        public void Login_SuccessUser_ReturnsExpectedUser()
        {
            // Arrange
            User expectedUser = new User()
            {
                Id          = 1,
                Username    = "******",
                Displayname = "พลอย"
            };
            IAuthenticationService service = service = new StubSuccessAuthenticationService();

            // Act
            User actualUser = service.Login(goodUser.Username, goodUser.Password);

            // Assert
            Assert.IsType <User>(actualUser);
            Assert.Equal(expectedUser.Id, actualUser.Id);
            Assert.Equal(expectedUser.Username, actualUser.Username);
            Assert.Equal(expectedUser.Displayname, actualUser.Displayname);
        }