Exemplo n.º 1
0
        public void ShouldReturnASingleMilestoneById()
        {
            //Arrange
            string expectedSQLStatement = "SELECT * FROM saver.Milestones WHERE Id = @Id;";

            Model.Milestone expectedMilestone = new Model.Milestone(1, 100, "Testing 1", null);

            //Setup the mocks
            mockDataAccess.Setup
            (
                da => da.ExecuteQuery <Model.Milestone>
                (
                    It.Is <string>(val => val.Equals(expectedSQLStatement)),
                    It.Is <Dictionary <string, object> >(val => (int)val["Id"] == expectedMilestone.Id)
                )
            )
            .Returns(new Model.Milestone[] { expectedMilestone });
            mockSqlStringService.Setup(ss => ss.GetSqlFromResource(It.IsAny <string>())).Returns(expectedSQLStatement);

            IMilestoneRepository repository = new MilestoneRepository(mockDataAccess.Object, mockSqlStringService.Object);

            //Act
            Model.Milestone returnedMilestone = repository.Get(expectedMilestone.Id);

            //Assert
            returnedMilestone.Should().NotBeNull();
            returnedMilestone.Should().BeEquivalentTo(expectedMilestone);
        }