示例#1
0
        public async Task OpenAirProcessor_ShouldReturnNoState()
        {
            var info = new TextDeconstructionInformation("Get unsubmitted timesheets", null);

            // Act
            var result = await _processor.ProcessCommandAsync(info, CreateEvent("[email protected]"), null, new Dictionary <string, string>()) as ChatEventResult;

            Assert.AreEqual("Provide a state of the time sheets, like unsubmitted or unapproved!", result.Text);
        }
示例#2
0
        public async Task OpenAirProcessor_ShouldReturnNoState()
        {
            var info     = new TextDeconstructionInformation("Get unsubmitted timesheets", null);
            var accessor = Substitute.For <IPluginPropertiesAccessor>();

            accessor.GetAllPluginPropertyValues <string>(null).ReturnsForAnyArgs(new string[0]);

            // Act
            var result = await _processor.ProcessCommandAsync(info, CreateEvent("[email protected]"), null, accessor) as ChatEventResult;

            Assert.AreEqual("Provide a state of the time sheets, like unsubmitted or unapproved!", result.Text);
        }
        public async Task WhenAskedItShouldGetTimesheets()
        {
            var sender  = new ChatEventMessageSender();
            var space   = new ChatEventSpace();
            var message = new ChatEventMessage {
                Sender = sender
            };
            var chat = new ChatEvent {
                Space = space, Message = message
            };
            var responder = Substitute.For <IHangoutsChatConnector>();
            var timesheet = new Timesheet {
                Name = "A", UserName = "******", UserEmail = "[email protected]", DepartmentName = "F", Total = 20
            };
            var info = new TextDeconstructionInformation("Get unsubmited timesheets", null, SentenceTypes.Command);

            _connector.GetUnsubmittedTimesheetsAsync(DateTime.MinValue).ReturnsForAnyArgs(new[] { timesheet });

            // Act
            var result = await _processor.ProcessCommandAsync(info, chat, responder);

            // Test
            System.Threading.Thread.Sleep(150);

            Assert.AreEqual(null, result.Text);
            responder
            .Received()
            .SendMessageAsync(
                null,
                Arg.Is <GoogleChatAddress>(it => it.Sender == sender && it.Space == space),
                Arg.Any <Card[]>());
        }