コード例 #1
0
        public void ShouldCreateProject(string name, ProjectId nextIdentity, Guid resultIdentity)
        {
            "Given name"
            .x(() => name = "project name");

            "And project repository that returns next identity".x(() =>
            {
                nextIdentity = ProjectId.New();

                _projectRepositoryMock
                .Setup(x => x.GetNextIdentity())
                .Returns(nextIdentity);
            });

            "When I create project"
            .x(() => resultIdentity = _sut.CreateProject(name));

            "Then project repository should save the project"
            .x(() => _projectRepositoryMock.Verify(x => x.Save(It.IsAny <Project>())));

            "And project identity should be returned"
            .x(() => Assert.Equal(nextIdentity.Value, resultIdentity));

            "And saved project should have valid name and identity".x(() =>
            {
                Assert.Equal(nextIdentity, _savedProject.GetState().ProjectId);
                Assert.Equal(name, _savedProject.GetState().Name.Value);
            });
        }