コード例 #1
0
        public void GivenCancelledActivity_WhenFinishingActivity_ThenActivityStateSetToCancelledAndDoesNotSetAssessmentSections()
        {
            // Given
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);

            var mocks   = new MockRepository();
            var service = mocks.StrictMock <ILoadAssessmentSectionService>();

            service.Expect(p => p.LoadAssessmentSection(null))
            .IgnoreArguments()
            .Return(assessmentSection);
            mocks.ReplayAll();

            var owner    = new AssessmentSectionOwner();
            var activity = new LoadAssessmentSectionActivity(owner, service, string.Empty);

            activity.Run();
            activity.Cancel();

            // When
            activity.Finish();

            // Assert
            Assert.AreEqual(ActivityState.Canceled, activity.State);
            Assert.IsNull(owner.AssessmentSection);
            mocks.VerifyAll();
        }
コード例 #2
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks   = new MockRepository();
            var service = mocks.StrictMock <ILoadAssessmentSectionService>();

            mocks.ReplayAll();

            var owner = new AssessmentSectionOwner();

            // Call
            var activity = new LoadAssessmentSectionActivity(owner, service, string.Empty);

            // Assert
            Assert.IsInstanceOf <Activity>(activity);
            Assert.AreEqual("Inlezen van project", activity.Description);
            Assert.AreEqual(ActivityState.None, activity.State);
            mocks.VerifyAll();
        }
コード例 #3
0
        public void Run_Always_SendsFilePathToGetAssessmentSections()
        {
            // Setup
            const string filePath = "File\\Path";

            var mocks   = new MockRepository();
            var service = mocks.StrictMock <ILoadAssessmentSectionService>();

            service.Expect(p => p.LoadAssessmentSection(filePath)).Return(new AssessmentSection(AssessmentSectionComposition.Dike));
            mocks.ReplayAll();

            var owner    = new AssessmentSectionOwner();
            var activity = new LoadAssessmentSectionActivity(owner, service, filePath);

            // Call
            activity.Run();

            // Assert
            mocks.VerifyAll();
        }
コード例 #4
0
        public void Run_ServiceThrowsException_SetsActivityStateToFailedAndDoesNotSetAssessmentSections()
        {
            // Setup
            var mocks   = new MockRepository();
            var service = mocks.StrictMock <ILoadAssessmentSectionService>();

            service.Expect(p => p.LoadAssessmentSection(null))
            .IgnoreArguments()
            .Throw(new LoadAssessmentSectionException());
            mocks.ReplayAll();

            var owner    = new AssessmentSectionOwner();
            var activity = new LoadAssessmentSectionActivity(owner, service, string.Empty);

            // Call
            activity.Run();

            // Assert
            Assert.AreEqual(ActivityState.Failed, activity.State);
            Assert.IsNull(owner.AssessmentSection);
            mocks.VerifyAll();
        }
コード例 #5
0
        public void Run_ServiceReturnsAssessmentSections_SetsActivityStateToExecutedAndSetsAssessmentSections()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);

            var mocks   = new MockRepository();
            var service = mocks.StrictMock <ILoadAssessmentSectionService>();

            service.Expect(p => p.LoadAssessmentSection(null))
            .IgnoreArguments()
            .Return(assessmentSection);
            mocks.ReplayAll();

            var owner    = new AssessmentSectionOwner();
            var activity = new LoadAssessmentSectionActivity(owner, service, string.Empty);

            // Call
            activity.Run();

            // Assert
            Assert.AreEqual(ActivityState.Executed, activity.State);
            Assert.AreSame(assessmentSection, owner.AssessmentSection);
            mocks.VerifyAll();
        }