Esempio n. 1
0
        public void GetVacationInfoTest()
        {
            using (new TransactionScope(TransactionScopeOption.RequiresNew))
                using (TimeTrackerDbContext dbContext = CreateTestContext()) {
                    // Arrange
                    int      userId     = 1091;
                    string   domainName = @"CORP\Maxim.Rozhkov";
                    DateTime from       = new DateTime(2018, 08, 24);
                    DateTime to         = new DateTime(2018, 09, 12);
                    dbContext.Vacations.Add(new Vacation(userId, from, to));
                    dbContext.SaveChanges();
                    var app = new VacationsApp(new UsersRepository(dbContext), new VacationsRepository(dbContext));

                    // Act
                    var rc = app.GetVacationInfo(domainName, new DateTime(2018, 08, 27));

                    //Assert
                    Assert.AreEqual(rc.Interval.Start, from);
                    Assert.AreEqual(rc.Interval.End, to);
                }
        }
Esempio n. 2
0
        public void SetVacationTest()
        {
            using (new TransactionScope(TransactionScopeOption.RequiresNew))
                using (TimeTrackerDbContext dbContext = CreateTestContext()) {
                    // Arrange
                    string   domainName = @"CORP\Maxim.Rozhkov";
                    DateTime from       = new DateTime(2018, 08, 24);
                    DateTime to         = new DateTime(2018, 09, 12);
                    var      app        = new VacationsApp(new UsersRepository(dbContext), new VacationsRepository(dbContext));

                    // Act
                    app.SetVacation(new VacationInfo {
                        DomainName = domainName,
                        Interval   = new TimeInterval(from, to),
                    });

                    //Assert
                    var vacation = dbContext.Vacations
                                   .Where(x => x.User.UserName == domainName && x.DateFrom == from && x.DateTo == to);
                    Assert.IsNotNull(vacation);
                }
        }
Esempio n. 3
0
 public SetVacationCommandHandler(VacationsApp vacationsApp, MessageSender messageSender, AppConfig appConfig)
 {
     _vacationsApp  = vacationsApp;
     _messageSender = messageSender;
     _slackClient   = new SlackClient(appConfig.SlackToken);
 }