Example #1
0
        public void CreateLibraryCommandExecute_WhenSuccess_ReturnsCommandResultWithSuccess()
        {
            var message = new CreateBookMessage { Title = "Books" };
            var command = GetCommandWithSession(message);

            var result = command.Execute();

            Assert.That(result.IsSuccess(), Is.True);
        }
Example #2
0
        public void CreateLibraryCommandExecute_Always_StoreAndSaveChanges()
        {
            var message = new CreateBookMessage { Title = "Books" };
            var command = GetCommandWithSession(message);

            command.Execute();

            sessionMock.Verify(s => s.Store(It.Is<Book>(l => l.Title == "Books")));
            sessionMock.Verify(s => s.SaveChanges());
        }
Example #3
0
        public void CreateLibraryCommandExecute_Always_SetsCurrentUserAsCreator()
        {
            var message = new CreateBookMessage { Title = "Books" };
            var command = GetCommandWithSession(message);
            var currentUser = new User();
            command.FakeCurrentUser = currentUser;

            command.Execute();

            sessionMock.Verify(s => s.Store(It.Is<Book>(l => l.Creator == currentUser)));
        }