public void GivenAliceWantsToReadCharliesWallButCharlieHasNoMessagesOnHisWallWhenProcessUserInputIsCalledThenTheProgramDisplaysNothing() { var repository = new UserRepository(); var broker = new MessageBroker(repository); var commandFactory = new CommandFactory(broker); var parser = new InputParser(commandFactory); this.consoleMock.ConsoleRead().Returns("charlie"); var program = new Program(this.consoleMock, parser, this.formaterFactoryMock); program.ProcessUserInput(); this.consoleMock.DidNotReceive().ConsoleWrite(string.Empty); }
public static void Main() { var repository = new UserRepository(); var broker = new MessageBroker(repository); var commandFactory = new CommandFactory(broker); var parser = new InputParser(commandFactory); var formaterFactory = new MessageFormaterFactory(); var consoleWrapper = new ConsoleWrapper(); var program = new Program(consoleWrapper, parser, formaterFactory); while (program.ProcessUserInput()) { } }
public void GivenAliceWantsToReadCharliesWallAndCharlieHasMessagesOnHisWallWhenProcessUserInputIsCalledThenTheProgramDisplaysCharliesWallMessagesAndHowLongHasCharliePostedEachMessage() { var repository = new UserRepository(); var broker = new MessageBroker(repository); var commandFactory = new CommandFactory(broker); var parser = new InputParser(commandFactory); var charlie = repository.Create("charlie"); charlie.Post("message from charlie"); this.consoleMock.ConsoleRead().Returns("charlie"); var program = new Program(this.consoleMock, parser, new MessageFormaterFactory()); program.ProcessUserInput(); this.consoleMock.Received().ConsoleWrite("message from charlie (0 seconds ago)"); }
public void SetUp() { this.repository = Substitute.For<IRepository<IUser>>(); this.userWall = Substitute.For<IWall>(); this.broker = new MessageBroker(this.repository); this.bob = new User("Bob", this.userWall); this.alice = new User("Alice", this.userWall); }
public void GivenCharlieAndAliceAreUsersInTheSystemAndCharlieFollowsAliceWhenAWallCommandOnCharlieIsRequestedThenCharliesWallShouldContainPostsFromAliceAndCharlie() { var repository = new UserRepository(); var broker = new MessageBroker(repository); var commandFactory = new CommandFactory(broker); var parser = new InputParser(commandFactory); var charlie = repository.Create("charlie"); repository.Create("alice"); var program = new Program(this.consoleMock, parser, new MessageFormaterFactory()); this.consoleMock.ConsoleRead().Returns("charlie follows alice"); program.ProcessUserInput(); this.consoleMock.ConsoleRead().Returns("charlie -> message from charlie"); program.ProcessUserInput(); this.consoleMock.ConsoleRead().Returns("alice -> message from alice"); program.ProcessUserInput(); this.consoleMock.ConsoleRead().Returns("charlie wall"); program.ProcessUserInput(); charlie.Wall.Count().Should().Be(2); }
public void GivenTheUserTypesAPostCommandWhenProcessUserInputIsCalledThenTheUserWallShouldContainPostedMessage() { var repository = new UserRepository(); var broker = new MessageBroker(repository); var commandFactory = new CommandFactory(broker); var parser = new InputParser(commandFactory); this.consoleMock.ConsoleRead().Returns("Bob -> my message"); var program = new Program(this.consoleMock, parser, this.formaterFactoryMock); program.ProcessUserInput(); var user = repository.FindByIdentifier("Bob"); user.Wall.Should().Contain(m => m.Body == "my message"); }
public void GivenTheUserTypesAPostCommandWhenProcessUserInputIsCalledThenPostOnUserWallIsInvokedIndirectely() { var broker = new MessageBroker(this.repositoryMock); var commandFactory = new CommandFactory(broker); var parser = new InputParser(commandFactory); this.consoleMock.ConsoleRead().Returns("Bob -> my message"); this.repositoryMock.FindByIdentifier("Bob").Returns(this.bob); var program = new Program(this.consoleMock, parser, this.formaterFactoryMock); program.ProcessUserInput(); this.userWallMock.Received().Post(this.bob, "my message"); }
public void GivenCharlieAndAliceAreUsersInTheSystemWhenCharlieFollowsAliceThenAliceFollowersShouldContainCharlie() { var repository = new UserRepository(); var broker = new MessageBroker(repository); var commandFactory = new CommandFactory(broker); var parser = new InputParser(commandFactory); var charlie = repository.Create("charlie"); var alice = repository.Create("alice"); this.consoleMock.ConsoleRead().Returns("charlie follows alice"); var program = new Program(this.consoleMock, parser, this.formaterFactoryMock); program.ProcessUserInput(); alice.Followers.Should().Contain(charlie); }
public void GivenCharlieAndAliceAreUsersInTheSystemAndCharlieFollowsAliceWhenAWallCommandOnCharlieIsRequestedThenItDisplayCharliesWallStatingTheAuthorOfThePosts() { var repository = new UserRepository(); var broker = new MessageBroker(repository); var commandFactory = new CommandFactory(broker); var parser = new InputParser(commandFactory); repository.Create("charlie"); repository.Create("alice"); var program = new Program(this.consoleMock, parser, new MessageFormaterFactory()); this.consoleMock.ConsoleRead().Returns("charlie follows alice"); program.ProcessUserInput(); this.consoleMock.ConsoleRead().Returns("charlie -> message from charlie"); program.ProcessUserInput(); this.consoleMock.ConsoleRead().Returns("alice -> message from alice"); program.ProcessUserInput(); this.consoleMock.ConsoleRead().Returns("charlie wall"); program.ProcessUserInput(); this.consoleMock.Received().ConsoleWrite("charlie - message from charlie (0 seconds ago)"); this.consoleMock.Received().ConsoleWrite("alice - message from alice (0 seconds ago)"); }