public void Should_Init_Handler() { IUserJoinsServerHandler handler = Substitute.For <IUserJoinsServerHandler>(); _client.Register(handler); handler.Received(1).Init(_client, Arg.Is <DataStoreLockDecorator>(decoratedDataStore => decoratedDataStore.DataStore == _dataStore)); }
public void Should_Not_Handle_If_ParsedCommand_Is_Not_Successful() { _parser.ParseCommand(Arg.Any <IMessage>()).Returns(ParsedCommand.Unsuccessful()); ICommandHandler commandHandler = Substitute.For <ICommandHandler>(); commandHandler.CommandName.Returns("test"); _discloseClient.Register(commandHandler); _discordClient.OnMessageReceived += Raise.EventWith(new object(), new MessageEventArgs(_message)); commandHandler.Received(0).Handle(Arg.Any <DiscloseMessage>(), Arg.Any <string>()); }
public void Setup() { _parser = Substitute.For <ICommandParser>(); _discordClient = Substitute.For <IDiscordClient>(); _discloseClient = new DiscloseClient(_discordClient, _parser); _discloseClient.Init(new DiscloseOptions()); _user = Substitute.For <IServerUser>(); _server = Substitute.For <IServer>(); _user.Id.Returns((ulong)1); _server.Id.Returns((ulong)2); _handler1 = Substitute.For <IUserJoinsServerHandler>(); _handler2 = Substitute.For <IUserJoinsServerHandler>(); _discloseClient.Register(_handler1); _discloseClient.Register(_handler2); _discordClient.OnServerAvailable += Raise.EventWith <ServerEventArgs>(new object(), new ServerEventArgs(_server)); }
public void Should_Throw_When_Two_Handlers_Have_The_Same_Command() { ICommandHandler handler1 = Substitute.For <ICommandHandler>(); ICommandHandler handler2 = Substitute.For <ICommandHandler>(); handler1.CommandName.Returns("test"); handler2.CommandName.Returns("test"); _client.Register(handler1); Action action = () => _client.Register(handler2); action.ShouldThrow <ArgumentException>(); }