Ejemplo n.º 1
0
        //[TestMethod]
        public void TestThatUpdateGoalUpdates()
        {
            Data.Team       team;
            Data.TeamMember teamMember;
            CreateTeamAndTeamMember(out team, out teamMember);

            _mockContainer.Goals.Add(new Data.Goal()
            {
                Completed = false, TeamId = team.Id, Id = 1
            });

            Core.Models.Goal goal = new Core.Models.Goal()
            {
                CapabilityId = 1,
                DueDate      = DateTime.Now.AddDays(1),
                Notes        = "Some Notes",
                Completed    = true
            };

            _controller.Put(1, goal);

            var updatedGoal = _mockContainer.Goals.Where(i => i.Id == 1).FirstOrDefault();

            Assert.IsNotNull(updatedGoal);
            Assert.IsTrue(updatedGoal.Completed == true);
            Assert.IsTrue(updatedGoal.DueDate == goal.DueDate);
        }
Ejemplo n.º 2
0
        public async Task Put_WhenInvalidModelState_ShouldReturnBadRequest(
            GoalModel goalModel,
            GoalController sut)
        {
            // Arranges
            sut.ModelState.AddModelError("Error key", "Error message");

            // Act
            var result = await sut.Put(goalModel);

            // Asserts
            result.Should().BeOfType <BadRequestObjectResult>();
            ((BadRequestObjectResult)result).Value.Should()
            .BeOfType <SerializableError>();
            sut.GoalMapper.DidNotReceive().Map(Arg.Any <GoalModel>());
            await sut.GoalService.DidNotReceive().UpdateAsync(Arg.Any <Goal>());
        }
Ejemplo n.º 3
0
        public async Task Put_ShouldReturnNoContent(
            Goal goal,
            GoalModel goalModel,
            GoalController sut)
        {
            // Arranges
            sut.GoalMapper.Map(Arg.Is(goalModel)).Returns(goal);
            sut.GoalService.UpdateAsync(Arg.Is(goal)).Returns(true);

            // Act
            var result = await sut.Put(goalModel);

            // Asserts
            result.Should().NotBeNull();
            result.Should().BeOfType <NoContentResult>();
            sut.GoalMapper.Received(1).Map(Arg.Is(goalModel));
            await sut.GoalService.Received(1).UpdateAsync(Arg.Is(goal));
        }
Ejemplo n.º 4
0
        public async Task Put_WhenUpdateAsyncFails_ShouldReturnNotModified(
            Goal goal,
            GoalModel goalModel,
            GoalController sut)
        {
            // Arranges
            sut.GoalMapper.Map(Arg.Is(goalModel)).Returns(goal);
            sut.GoalService.UpdateAsync(Arg.Is(goal)).Returns(false);

            // Act
            var result = await sut.Put(goalModel);

            // Asserts
            result.Should().NotBeNull();
            result.Should().BeOfType <StatusCodeResult>();
            ((StatusCodeResult)result).StatusCode.Should().Be(304);
            sut.GoalMapper.Received(1).Map(Arg.Is(goalModel));
            await sut.GoalService.Received(1).UpdateAsync(Arg.Is(goal));
        }