public void GetWithWhereClauseButNoneMatchSuccessTest()
        {
            //Given
            var databseFactory =
                new EfCoreDatabaseFactoryBase <SharedLibraryContext>("SharedLibraryContext");

            var repository = new EfCoreAccountRepository(databseFactory);

            //When
            var shouldBeNull = repository.Get(x => false);

            //Then
            Assert.IsNull(shouldBeNull, "No item should have been found.");
        }
Example #2
0
        public async Task <TodayAttendanceDto> Login(LoginDto model)
        {
            var account = await _accountRepository.Get(model.Email, model.Password);

            if (account == null)
            {
                return(null);
            }

            var attendance = await _attendanceRepository.GetTodayAccountAttendance(account.Id);

            return(new TodayAttendanceDto
            {
                AccountId = account.Id,
                Name = account.Name,
                Date = attendance?.Date ?? DateTime.Now.Date,
                Login = attendance?.Login?.ToString(),
                Logout = attendance?.Logout?.ToString()
            });
        }
        public void GetWithWhereClauseSuccessTest()
        {
            //Given
            var databseFactory =
                new EfCoreDatabaseFactoryBase <SharedLibraryContext>("SharedLibraryContext");

            using (var efCoreUnitOfWork = new EfCoreUnitOfWork <SharedLibraryContext>(databseFactory))
            {
                var repository  = new EfCoreAccountRepository(databseFactory);
                var listOfItems = AccountEntityHelper.CreateEfCoreTestAccounts(3);
                listOfItems[2].CompanyName = "TestReferenceOtherValue";
                repository.AddRange(listOfItems);
                efCoreUnitOfWork.Commit();

                //When
                var items = repository.Get(x => x.CompanyName.Contains("TestReference"));

                //Then
                EqualityHelper.PropertyValuesAreEqual(items, listOfItems[2],
                                                      new[] { "AccountID", "LastModified", "LastModifiedBy", "Contacts" });
            }
        }