コード例 #1
0
        public void GetDiseasesInCategory_InCorrectInputCategotyId_ExpectedException()
        {
            // Arrange
            TestData testData         = new TestData();
            var      mockDataProvider = new Mock <IDataAccessManager>();

            mockDataProvider.Setup(mock => mock.GetDiseasesInCategory(testData.disease.CategoryId)).
            Returns(testData.Diseases);
            var service = new DiseaseManager(mockDataProvider.Object);

            // Act
            List <Disease> diseases = service.GetDiseasesInCategory(testData.disease.CategoryId).ToList();
        }
コード例 #2
0
        public void GetDiseasesInCategory_CorrectInputCategotyId_ListOfDiseases()
        {
            // Arrange
            TestData testData         = new TestData();
            var      mockDataProvider = new Mock <IDataAccessManager>();

            mockDataProvider.Setup(mock => mock.GetDiseaseCategories()).Returns(testData.Categories);
            mockDataProvider.Setup(mock => mock.GetDiseasesInCategory(testData.disease.CategoryId)).
            Returns(testData.Diseases);
            var service = new DiseaseManager(mockDataProvider.Object);

            // Act
            List <Disease> diseases = service.GetDiseasesInCategory(testData.disease.CategoryId).ToList();

            // Assert
            CollectionAssert.AreEqual(testData.Diseases, diseases);
        }