Esempio n. 1
0
        public void Cannot_Get_All_Custom_Data_From_Project()
        {
            //Arrange

            var projectRepositoryMock = new Mock <IProjectRepository>();

            projectRepositoryMock.Setup(m => m.GetByIdWithCustomDatas(It.IsAny <int>()))
            .Returns(new Project
            {
                ProjectCustomData = new List <ProjectCustomData>
                {
                    new ProjectCustomData(),
                    new ProjectCustomData()
                }
            });

            //Act

            var target = new GetAllCustomDataFromProject(projectRepositoryMock.Object);
            var result = target.Invoke(1);

            //Assert

            Assert.True(result.Count == 2);
        }
Esempio n. 2
0
        public void Cannot_Get_All_Custom_Data_From_Non_Existing_Project()
        {
            //Arrange

            var projectRepositoryMock = new Mock <IProjectRepository>();

            projectRepositoryMock.Setup(m => m.GetByIdWithCustomDatas(It.IsAny <int>())).Returns(() => null);

            //Act

            var target = new GetAllCustomDataFromProject(projectRepositoryMock.Object);

            //Assert

            var result = Assert.Throws <Exception>(() => target.Invoke(1));

            Assert.True(result.Message.Contains("Could not find project with ID:"));
        }