Пример #1
0
        public void LoadAssessmentSection_Always_SendsFilePathToLoadsProject()
        {
            // Setup
            const string filePath = "Some\\path";

            var mocks        = new MockRepository();
            var storeProject = mocks.StrictMock <IStoreProject>();

            storeProject.Expect(sp => sp.LoadProject(filePath)).Return(CreateProject());
            mocks.ReplayAll();

            var service = new LoadAssessmentSectionService(storeProject);

            // Call
            service.LoadAssessmentSection(filePath);

            // Assert
            mocks.VerifyAll();
        }
Пример #2
0
        public void LoadAssessmentSection_LoadedProjectNull_ThrowsLoadAssessmentSectionException()
        {
            // Setup
            var mocks        = new MockRepository();
            var storeProject = mocks.StrictMock <IStoreProject>();

            storeProject.Expect(sp => sp.LoadProject(null))
            .IgnoreArguments()
            .Return(null);
            mocks.ReplayAll();

            var service = new LoadAssessmentSectionService(storeProject);

            // Call
            void Call() => service.LoadAssessmentSection(string.Empty);

            // Assert
            Assert.Throws <LoadAssessmentSectionException>(Call);
            mocks.VerifyAll();
        }
Пример #3
0
        public void LoadAssessmentSection_LoadingProjectSuccessful_ReturnsRiskeerProject()
        {
            // Setup
            RiskeerProject project = CreateProject();

            var mocks        = new MockRepository();
            var storeProject = mocks.StrictMock <IStoreProject>();

            storeProject.Expect(sp => sp.LoadProject(null))
            .IgnoreArguments()
            .Return(project);
            mocks.ReplayAll();

            var service = new LoadAssessmentSectionService(storeProject);

            // Call
            AssessmentSection assessmentSection = service.LoadAssessmentSection(string.Empty);

            // Assert
            Assert.AreSame(project.AssessmentSection, assessmentSection);
            mocks.VerifyAll();
        }
Пример #4
0
        public void LoadAssessmentSection_LoadingProjectThrowsException_ThrowsLoadAssessmentSectionExceptionAndLogsError()
        {
            // Setup
            const string exceptionMessage = "StorageException";
            var          storageException = new StorageException(exceptionMessage);

            var mocks        = new MockRepository();
            var storeProject = mocks.StrictMock <IStoreProject>();

            storeProject.Expect(sp => sp.LoadProject(null))
            .IgnoreArguments()
            .Throw(storageException);
            mocks.ReplayAll();

            var service = new LoadAssessmentSectionService(storeProject);

            LoadAssessmentSectionException exception = null;

            // Call
            void Call()
            {
                try
                {
                    service.LoadAssessmentSection(string.Empty);
                }
                catch (LoadAssessmentSectionException e)
                {
                    exception = e;
                }
            }

            // Assert
            var expectedLogMessage = new Tuple <string, LogLevelConstant>(exceptionMessage, LogLevelConstant.Error);

            TestHelper.AssertLogMessageWithLevelIsGenerated(Call, expectedLogMessage);
            Assert.AreEqual(storageException, exception.InnerException);
            Assert.AreEqual(storageException.Message, exception.Message);
            mocks.VerifyAll();
        }