Exemple #1
0
    public async Task Run_InvalidStartDate_DoesNotCreateEvent()
    {
        this.GetDependency <IConsole>().AskForText(Arg.Any <string>()).Returns(this.Summary);
        this.GetDependency <IConsole>().AskForDate(Arg.Is <string>(s => s.Contains("start date"))).Returns(null as DateTime?);
        this.GetDependency <IConsole>().AskForDate(Arg.Is <string>(s => s.Contains("end date"))).Returns(this.EndDate);
        var calendar = new External.GoogleCalendar.Client.Models.Calendar {
            Id = "My calendar id"
        };

        this.GetDependency <IChooseCalendarStepHandler>().Run().Returns(calendar);

        await this.Target.Run();

        await this.GetDependency <IEventManagementService>().DidNotReceive().CreateEvent(Arg.Any <string>(), Arg.Any <Event>());
    }
Exemple #2
0
    public async Task Run_InvalidEndDate_UsesStartDatePlus30Minutes()
    {
        this.GetDependency <IConsole>().AskForText(Arg.Any <string>()).Returns(this.Summary);
        this.GetDependency <IConsole>().AskForDate(Arg.Is <string>(s => s.Contains("start date"))).Returns(this.StartDate);
        this.GetDependency <IConsole>().AskForDate(Arg.Is <string>(s => s.Contains("end date"))).Returns(null as DateTime?);
        var calendar = new External.GoogleCalendar.Client.Models.Calendar {
            Id = "My calendar id"
        };

        this.GetDependency <IChooseCalendarStepHandler>().Run().Returns(calendar);

        await this.Target.Run();

        await this.GetDependency <IEventManagementService>().Received().CreateEvent(
            calendar.Id,
            Arg.Is <Event>(e => e.Summary == this.Summary &&
                           e.Start.Value == this.StartDate &&
                           e.End.Value == this.StartDate.AddMinutes(30)));
    }