コード例 #1
0
        public void Add_NewUser_Returns200OK(string name, string username, string password)
        {
            var expected = new UserTransferObject
            {
                name     = name,
                username = username,
                password = password
            };

            var builder     = new UserControllerBuilder();
            var serviceMock = builder.GetDefaultUserService();

            serviceMock.Setup(r => r.AddUser(It.IsAny <UserTransferObject>()))
            .Returns(ServiceResult <UserTransferObject> .SuccessResult(
                         new UserTransferObject
            {
                name     = name,
                username = username,
                password = password
            }));

            var controller = builder.WithUserService(serviceMock.Object).Build();

            var response = controller.addUsers(expected);

            Assert.IsType <OkObjectResult>(response);
        }
コード例 #2
0
        public void GetAll_User_Returns200OK()
        {
            var builder     = new UserControllerBuilder();
            var serviceMock = builder.GetDefaultUserService();

            serviceMock.Setup(r => r.getAll())
            .Returns(ServiceResult <IEnumerable <UserTransferObject> > .SuccessResult(
                         Enumerable.Empty <UserTransferObject>()));

            var controller = builder.WithUserService(serviceMock.Object).Build();
            var response   = controller.getUsers();

            Assert.IsType <OkObjectResult>(response);
        }