Beispiel #1
0
        public async Task EmployeeRepository_Get_Call_GetResults_Test()
        {
            var context    = new MyCompanyContext();
            int employeeId = context.Employees.FirstOrDefault().EmployeeId;

            var result = await target.GetAsync(employeeId);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.EmployeeId == employeeId);
        }
Beispiel #2
0
        public async Task EmployeeRepository_GetAllEmployees_Call_GetResults_Test()
        {
            var context       = new MyCompanyContext();
            int expectedCount = context.Employees.Count();

            var results = await target.GetAllAsync();

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Any());
        }
Beispiel #3
0
        public async Task VisitorRepository_GetCount_Filtered_Test()
        {
            var context  = new MyCompanyContext();
            var visitors = context.Visitors;

            var target = new VisitorRepository(context);
            var actual = await target.GetCountAsync(visitors.First().Company);

            Assert.IsTrue(actual == 1);
        }
        public async Task TravelRequestRepository_GetAllCount_Test()
        {
            var context = new MyCompanyContext();
            int status  = (int)(TravelRequestStatus.Approved | TravelRequestStatus.Denied | TravelRequestStatus.Completed | TravelRequestStatus.Pending);

            var target = new TravelRequestRepository(new MyCompanyContext());
            var result = await target.GetAllCountAsync(string.Empty, status);

            Assert.AreEqual(context.TravelRequests.Count(), result);
        }
Beispiel #5
0
        public async Task VisitorRepository_GetCount_Test()
        {
            var context       = new MyCompanyContext();
            int expectedCount = context.Visitors.Count();

            var target = new VisitorRepository(context);
            var actual = await target.GetCountAsync(string.Empty);

            Assert.AreEqual(expectedCount, actual);
        }
Beispiel #6
0
        public async Task TeamRepository_GetAllTeams_Call_GetResults_Test()
        {
            var context       = new MyCompanyContext();
            int expectedCount = context.Teams.Count();

            var target  = new TeamRepository(context);
            var results = await target.GetAllAsync();

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Any());
        }
        public async Task TravelRequestRepository_GetTravelRequest_Call_GetResults_Test()
        {
            var context         = new MyCompanyContext();
            int TravelRequestId = context.TravelRequests.FirstOrDefault().TravelRequestId;

            var target = new TravelRequestRepository(new MyCompanyContext());
            var result = await target.GetAsync(TravelRequestId);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.TravelRequestId == TravelRequestId);
        }
Beispiel #8
0
        public async Task GetUserChannels_ShouldReturn2Channels_ForTheFirstEmployee()
        {
            var context      = new MyCompanyContext();
            var userIdentity = context.Employees.FirstOrDefault(e => e.Expenses.Any()).Email;

            var notificationChannels = await notificationChannelRepository.GetUserChannelsAsync(userIdentity);

            Assert.AreEqual(2, notificationChannels.Count());
            Assert.IsTrue(notificationChannels.Any(nc => nc.NotificationType == NotificationType.WindowsPhoneNotification));
            Assert.IsTrue(notificationChannels.Any(nc => nc.NotificationType == NotificationType.WindowsStoreNotification));
        }
Beispiel #9
0
        public void ExpenseRepository_GetTeamMemberExpensesByMonth_EmptyResults_Test()
        {
            var context     = new MyCompanyContext();
            int expenseType = (int)(ExpenseType.Unknown);
            var employeeId  = context.Employees.FirstOrDefault(e => e.Expenses.Any()).EmployeeId;

            var results = target.GetTeamMemberExpensesByMonth(employeeId, expenseType);

            Assert.IsNotNull(results);
            Assert.IsFalse(results.Any());
        }
Beispiel #10
0
        public async Task ExpenseRepository_GetUserCount_NoResults_Test()
        {
            var context       = new MyCompanyContext();
            int expectedCount = context.Expenses.Count();
            var userIdentity  = context.Employees.FirstOrDefault(e => e.Expenses.Any()).Email;
            int expenseStatus = (int)ExpenseStatus.Unknown;

            var count = await target.GetUserCountAsync(userIdentity, expenseStatus);

            Assert.IsTrue(count == 0);
        }
        public async Task EmployeeRepository_GetCompleteInfo_Call_GetResults_Test()
        {
            var context    = new MyCompanyContext();
            int employeeId = context.Employees.FirstOrDefault().EmployeeId;

            var target = new EmployeeRepository(context);
            var result = await target.GetCompleteInfoAsync(employeeId, PictureType.All);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.EmployeeId == employeeId);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="securityHelper">context</param>
 /// <param name="vacationRequestRepository">context</param>
 /// <param name="vacationNotificationService">context</param>
 public VacationRequestsODataController(
     MyCompanyContext context,
     ISecurityHelper securityHelper,
     IVacationRequestRepository vacationRequestRepository,
     IVacationNotificationService vacationNotificationService)
 {
     _context                     = context;
     _securityHelper              = securityHelper;
     _vacationRequestRepository   = vacationRequestRepository;
     _vacationNotificationService = vacationNotificationService;
 }
Beispiel #13
0
        public void EmployeeRepository_GetAllEmployees_Call_GetResults_Test()
        {
            var context       = new MyCompanyContext();
            int expectedCount = context.Employees.Count();

            var target  = new EmployeeRepository(context);
            var results = target.GetAll().ToList();

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Any());
        }
Beispiel #14
0
        public void EmployeeRepository_GetEmployee_Call_GetResults_Test()
        {
            var context    = new MyCompanyContext();
            int employeeId = context.Employees.FirstOrDefault().EmployeeId;

            var target = new EmployeeRepository(context);
            var result = target.Get(employeeId);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.EmployeeId == employeeId);
        }
        public async Task TravelRequestRepository_GetUserCount_Test()
        {
            var context  = new MyCompanyContext();
            var employee = context.Employees.Include("Travels").FirstOrDefault(e => e.Travels.Any());
            int status   = (int)(TravelRequestStatus.Approved | TravelRequestStatus.Denied | TravelRequestStatus.Completed | TravelRequestStatus.Pending);

            var target = new TravelRequestRepository(new MyCompanyContext());
            var result = await target.GetUserCountAsync(employee.Email, string.Empty, status);

            Assert.AreEqual(employee.Travels.Count(), result);
        }
Beispiel #16
0
        public async Task TeamRepository_DeleteTeam_NoExists_NotFail_Test()
        {
            var context  = new MyCompanyContext();
            int expected = context.Teams.Count();

            await target.DeleteAsync(-1);

            int actual = context.Teams.Count();

            Assert.AreEqual(expected, actual);
        }
Beispiel #17
0
        public void ExpenseRepository_GetTeamExpensesByMonth_EmptyResults_Test()
        {
            var context         = new MyCompanyContext();
            int expenseType     = (int)(ExpenseType.Unknown);
            var managerIdentity = context.Employees.FirstOrDefault(e => e.ManagedTeams.Any()).Email;

            var results = target.GetTeamExpensesByMonth(managerIdentity, expenseType);

            Assert.IsNotNull(results);
            Assert.IsFalse(results.Any());
        }
Beispiel #18
0
        public async Task ExpenseRepository_GetUserCount_Test()
        {
            var context       = new MyCompanyContext();
            int expectedCount = context.Expenses.Count();
            var userIdentity  = context.Employees.FirstOrDefault(e => e.Expenses.Any()).Email;
            int expenseStatus = (int)(ExpenseStatus.Approved | ExpenseStatus.Denied | ExpenseStatus.Pending);

            var count = await target.GetUserCountAsync(userIdentity, expenseStatus);

            Assert.IsTrue(count > 0);
        }
        public async Task TravelRequestRepository_GetTeamTravelDistribution_Test()
        {
            var context         = new MyCompanyContext();
            var managerIdentity = context.Employees.FirstOrDefault(e => e.ManagedTeams.Any() && e.Travels.Any()).Email;

            var target  = new TravelRequestRepository(new MyCompanyContext());
            var results = await target.GetTeamTravelDistributionAsync(managerIdentity, 5);

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Any());
        }
Beispiel #20
0
        public void ExpenseRepository_GetTeamExpensesByMonth_Test()
        {
            var context         = new MyCompanyContext();
            int expenseType     = (int)(ExpenseType.Accommodation | ExpenseType.Food | ExpenseType.Other | ExpenseType.Travel);
            var managerIdentity = context.Employees.FirstOrDefault(e => e.ManagedTeams.Any()).Email;

            var results = target.GetTeamExpensesByMonth(managerIdentity, expenseType);

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Any());
        }
Beispiel #21
0
        public async Task VisitorRepository_GetVisitor_Call_GetResults_Test()
        {
            var context   = new MyCompanyContext();
            int visitorId = context.Visitors.FirstOrDefault().VisitorId;

            var target = new VisitorRepository(context);
            var result = await target.GetAsync(visitorId);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.VisitorId == visitorId);
        }
Beispiel #22
0
        public void ExpenseRepository_GetTeamMemberExpensesByMonth_Test()
        {
            var context     = new MyCompanyContext();
            int expenseType = (int)(ExpenseType.Accommodation | ExpenseType.Food | ExpenseType.Other | ExpenseType.Travel);
            var employeeId  = context.Employees.FirstOrDefault(e => e.Expenses.Any()).EmployeeId;

            var results = target.GetTeamMemberExpensesByMonth(employeeId, expenseType);

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Any());
        }
Beispiel #23
0
        public async Task TeamRepository_GetTeam_Call_GetResults_Test()
        {
            var context = new MyCompanyContext();
            int teamId  = context.Teams.FirstOrDefault().TeamId;

            var target = new TeamRepository(context);
            var result = await target.GetAsync(teamId);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.TeamId == teamId);
        }
Beispiel #24
0
        public async Task VisitorPictureRepository_GetVisitorPictureByVisitorId_Call_GetResults_Test()
        {
            var context        = new MyCompanyContext();
            var visitorPicture = context.VisitorPictures.FirstOrDefault();

            var target = new VisitorPictureRepository(new MyCompanyContext());
            var result = await target.GetAsync(visitorPicture.VisitorId, visitorPicture.PictureType);

            Assert.IsNotNull(result);
            Assert.AreEqual(visitorPicture.VisitorPictureId, result.VisitorPictureId);
        }
Beispiel #25
0
        public async Task ExpenseRepository_DeleteExpenseTravel_NoExists_NotFail_Test()
        {
            var context  = new MyCompanyContext();
            int expected = context.ExpenseTravels.Count();

            await target.DeleteAsync(0);

            int actual = context.ExpenseTravels.Count();

            Assert.AreEqual(expected, actual);
        }
Beispiel #26
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="eventBus"></param>
        /// <param name="eventBusEnabled"></param>
        /// <param name="context">The EF context</param>
        public ExpenseRepository(MyCompany.Common.EventBus.IEventBus eventBus, bool eventBusEnabled, MyCompanyContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            _context         = context;
            _eventBusEnabled = eventBusEnabled;
            _eventBus        = eventBus;
        }
Beispiel #27
0
        public async Task EmployeePictureRepository_DeleteEmployeePicture_NoExists_NotFail_Test()
        {
            var context  = new MyCompanyContext();
            int expected = context.EmployeePictures.Count();

            IEmployeePictureRepository target = new EmployeePictureRepository(context);
            await target.DeleteAsync(0);

            int actual = context.EmployeePictures.Count();

            Assert.AreEqual(expected, actual);
        }
Beispiel #28
0
        public async Task ExpenseRepository_UpdateExpense_NotFail_Test()
        {
            var context = new MyCompanyContext();
            var expense = context.Expenses.FirstOrDefault();

            expense.Name = Guid.NewGuid().ToString();
            await target.UpdateAsync(expense);

            var actual = await target.GetAsync(expense.ExpenseId);

            Assert.AreEqual(expense.Name, actual.Name);
        }
Beispiel #29
0
        public async Task ExpenseRepository_GetTeamMemberSummaryExpenses_EmptyResults_Test()
        {
            var context = new MyCompanyContext();
            int month   = 0;
            int year    = 0;

            var employeeId = context.Employees.FirstOrDefault(e => e.Expenses.Any()).EmployeeId;

            var results = await target.GetTeamMemberSummaryExpensesAsync(employeeId, month, year);

            Assert.IsNotNull(results);
        }
Beispiel #30
0
        public async Task ExpenseRepository_GetTeamMemberSummaryExpenses_MonthNull_Test()
        {
            var context = new MyCompanyContext();

            var employeeId = context.Employees.FirstOrDefault(e => e.Expenses.Any()).EmployeeId;
            var datetime   = context.Expenses.Where(e => e.EmployeeId == employeeId).First().CreationDate;

            var results = await target.GetTeamMemberSummaryExpensesAsync(employeeId, null, datetime.Year);

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Any());
        }