예제 #1
0
        public void UpdateWithValidObject_ReturnOk()
        {
            _service.Setup(r => r.Update(It.IsAny <GroupBO>())).Returns((GroupBO group) => group);
            var result = _controller.Put(1, new GroupBO {
                Id = 1, ContactEmail = "D4FF"
            });

            Assert.IsType <OkObjectResult>(result);
        }
예제 #2
0
        public async void Can_Update_Group()
        {
            Scaffold.Config();

            var group = new UserGroupPoco
            {
                GroupId = 12,
                Name    = "PublisherUpdated",
                Alias   = "publisherUpdated",
                Users   = new List <User2UserGroupPoco>()
            };

            object result = await(await _groupsController.Put(group)).GetContent();

            Assert.Equal(MagicStrings.GroupUpdated.Replace("{name}", "PublisherUpdated"), result.Get("msg"));
        }
        public async Task UpdateGroup_RequiresGroup()
        {
            var service    = new Mock <IGroupService>(MockBehavior.Strict);
            var controller = new GroupsController(service.Object, Mapper.Instance);


            var result = await controller.Put(1, null) as BadRequestResult;

            Assert.IsNotNull(result);
        }
예제 #4
0
        public void ModifyGroup_InvalidGroup_ReturnsBadRequest()
        {
            var fakeSaveResult = new SaveResultModel <Group>
            {
                Model   = null,
                Success = false
            };

            var groupServiceMock = new Mock <IGroupService>();

            groupServiceMock.Setup(m => m.ModifyGroup(It.IsAny <Group>())).Returns(fakeSaveResult);
            controller = new GroupsController(groupServiceMock.Object, Mock.Of <IExpenseService>());

            var result = controller.Put(null);

            Assert.IsTrue(result != null);
            Assert.IsInstanceOfType(result, typeof(BadRequestResult));
        }
예제 #5
0
        public void ModifyGroup_ValidGroup_ReturnsOk()
        {
            var fakeSaveResult = new SaveResultModel <Group>
            {
                Model   = null,
                Success = true
            };

            var groupServiceMock = new Mock <IGroupService>();

            groupServiceMock.Setup(m => m.ModifyGroup(It.IsAny <Group>())).Returns(fakeSaveResult);
            controller = new GroupsController(groupServiceMock.Object, Mock.Of <IExpenseService>());

            var result = controller.Put(new Group {
                Name = "Group"
            });

            Assert.IsTrue(result != null);
            Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult <Group>));
        }
        public async Task UpdateGroup_ReturnsUpdatedGroup()
        {
            var group = new GroupInputViewModel
            {
                Name = "Group"
            };
            var service = new Mock <IGroupService>();

            service.Setup(x => x.GetById(2))
            .Returns(Task.FromResult(new Group
            {
                Id   = 2,
                Name = group.Name
            }))
            .Verifiable();

            var controller = new GroupsController(service.Object, Mapper.Instance);

            var result = await controller.Put(2, group) as NoContentResult;

            Assert.IsNotNull(result);
            service.VerifyAll();
        }