Inheritance: System.Web.UI.Page
        public void TestEmployeePayHistoryRepositoryAdd(EmployeePayHistory _EmployeePayHistory)
        {
            var _EmployeePayHistoryRepository = RepositoryHelper.GetEmployeePayHistoryRepository();

            _EmployeePayHistoryRepository.Add(_EmployeePayHistory);
            _EmployeePayHistoryRepository.Save();
        }
Esempio n. 2
0
        /// <summary>
        /// Deep load all EmployeePayHistory children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock           = CreateMockInstance(tm);
                mockCollection = DataRepository.EmployeePayHistoryProvider.GetPaged(tm, 0, 10, out count);

                DataRepository.EmployeePayHistoryProvider.DeepLoading += new EntityProviderBaseCore <EmployeePayHistory, EmployeePayHistoryKey> .DeepLoadingEventHandler(
                    delegate(object sender, DeepSessionEventArgs e)
                {
                    if (e.DeepSession.Count > 3)
                    {
                        e.Cancel = true;
                    }
                }
                    );

                if (mockCollection.Count > 0)
                {
                    DataRepository.EmployeePayHistoryProvider.DeepLoad(tm, mockCollection[0]);
                    System.Console.WriteLine("EmployeePayHistory instance correctly deep loaded at 1 level.");

                    mockCollection.Add(mock);
                    // DataRepository.EmployeePayHistoryProvider.DeepSave(tm, mockCollection);
                }

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
Esempio n. 3
0
        public async Task ShouldUpdateOneEmployeePayHistoryRecord()
        {
            ResetDatabase();

            var payHistory = new EmployeePayHistory
            {
                BusinessEntityID = 17,
                RateChangeDate   = new DateTime(2008, 1, 6),
                Rate             = 50.00M,
                PayFrequency     = PayFrequency.Biweekly
            };

            string      jsonPayHistory = JsonConvert.SerializeObject(payHistory);
            HttpContent content        = new StringContent(jsonPayHistory, Encoding.UTF8, "application/json");
            var         response       = await _client.PutAsync($"{serviceAddress}{rootAddress}/payhistory", content);

            Assert.True(response.IsSuccessStatusCode);
            Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);

            var test = await _client
                       .GetAsync($"{serviceAddress}{rootAddress}/payhistory/{payHistory.BusinessEntityID}/{payHistory.RateChangeDate.ToString("yyyy-MM-dd")}");

            var jsonResponse = await test.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <EmployeePayHistory>(jsonResponse);

            Assert.Equal(payHistory.Rate, result.Rate);
        }
Esempio n. 4
0
 public static void Map(this EmployeePayHistory destination, EmployeePayHistory source)
 {
     destination.BusinessEntityID = source.BusinessEntityID;
     destination.RateChangeDate   = source.RateChangeDate;
     destination.Rate             = source.Rate;
     destination.PayFrequency     = source.PayFrequency;
 }
        public void TestEmployeePayHistoryRepositoryDelete(EmployeePayHistory _EmployeePayHistory)
        {
            var _EmployeePayHistoryRepository = RepositoryHelper.GetEmployeePayHistoryRepository();

            _EmployeePayHistoryRepository.Repository.Delete(_EmployeePayHistory);
            _EmployeePayHistoryRepository.Save();
        }
        ///<summary>
        ///  Update the Typed EmployeePayHistory Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, EmployeePayHistory mock)
        {
            EmployeePayHistoryTest.UpdateMockInstance_Generated(tm, mock);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);
        }
Esempio n. 7
0
 public ViewEmployeePayHistory(EmployeePayHistory employee)
 {
     this.BusinessEntityID = employee.BusinessEntityID;
     this.RateChangeDate   = employee.RateChangeDate;
     this.Rate             = employee.Rate;
     this.PayFrequency     = employee.PayFrequency;
     this.ModifiedDate     = employee.ModifiedDate;
 }
 public EmployeePayHistoryModel Create(EmployeePayHistory eph)
 {
     return(new EmployeePayHistoryModel()
     {
         Rate = eph.Rate,
         ModifiedDate = eph.ModifiedDate,
         PayFrequency = eph.PayFrequency,
         RateChangeDate = eph.RateChangeDate
     });
 }
Esempio n. 9
0
        /// <summary>
        /// Converts the dto to entities.
        /// </summary>
        /// <param name="_EmployeePayHistoryDto">The EmployeePayHistory dto.</param>
        /// <returns>EmployeePayHistory</returns>
        public EmployeePayHistory ConvertDtoToEntities(EmployeePayHistoryDto _EmployeePayHistoryDto)
        {
            if (_EmployeePayHistoryDto == null)
            {
                throw new ArgumentNullException("model should not be null");
            }
            var efEmployeePayHistory = new EmployeePayHistory();

            ConvertObject(_EmployeePayHistoryDto, efEmployeePayHistory);
            return(efEmployeePayHistory);
        }
Esempio n. 10
0
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                EmployeePayHistory entity = mock.Copy() as EmployeePayHistory;
                entity = (EmployeePayHistory)mock.Clone();
                Assert.IsTrue(EmployeePayHistory.ValueEquals(entity, mock), "Clone is not working");
            }
        }
        // PUT api/awbuildversion/5
        public void Put(EmployeePayHistory value)
        {
            var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();

            if (GetActionType.Key != null)
            {
                if (GetActionType.Value.ToList()[0].Equals("DELETE"))
                    adventureWorks_BC.EmployeePayHistoryDelete(value);
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                    adventureWorks_BC.EmployeePayHistoryUpdate(value);
            }
        }
Esempio n. 12
0
        ///<summary>
        ///  Update the Typed EmployeePayHistory Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance_Generated(TransactionManager tm, EmployeePayHistory mock)
        {
            mock.Rate         = TestUtility.Instance.RandomShort();
            mock.PayFrequency = TestUtility.Instance.RandomByte();
            mock.ModifiedDate = TestUtility.Instance.RandomDateTime();

            //OneToOneRelationship
            Employee mockEmployeeByEmployeeId = EmployeeTest.CreateMockInstance(tm);

            DataRepository.EmployeeProvider.Insert(tm, mockEmployeeByEmployeeId);
            mock.EmployeeId = mockEmployeeByEmployeeId.EmployeeId;
        }
Esempio n. 13
0
        public void TransformEmployeePayHistory()
        {
            var adapter = new TypeAdapter();
            var eph     = new EmployeePayHistory()
            {
                EmployeeID   = 1,
                ModifiedDate = DateTime.Now
            };
            var dto = adapter.Transform <EmployeePayHistory, EmployeePayHistoryDto>(eph);

            Assert.Equal(1, dto.EmployeeID);
        }
Esempio n. 14
0
        /// <summary>
        /// Converts the dto to entities.
        /// </summary>
        /// <param name="_EmployeePayHistoryDto">The EmployeePayHistory dto.</param>
        /// <param name="skipNullPropertyValue">if set to <c>true</c> [skip null property value].</param>
        /// <returns>EmployeePayHistory</returns>
        public EmployeePayHistory ConvertDtoToEntities(EmployeePayHistoryDto _EmployeePayHistoryDto, bool skipNullPropertyValue)
        {
            if (_EmployeePayHistoryDto == null)
            {
                throw new ArgumentNullException("model should not be null");
            }

            var efEmployeePayHistory = new EmployeePayHistory();

            ConvertObjectWithCheckNull(_EmployeePayHistoryDto, skipNullPropertyValue, efEmployeePayHistory);
            return(efEmployeePayHistory);
        }
Esempio n. 15
0
        public void TransformEmployeePayHistory()
        {
            var adapter = new TypeAdapter<EmployeePayHistory, EmployeePayHistoryDTO>();
            var eph = new EmployeePayHistory()
            {
                EmployeeID = 1,
                ModifiedDate = DateTime.Now
            };
            var dto = adapter.Transform<EmployeePayHistory, EmployeePayHistoryDTO>(eph);

            Assert.Equal(1, dto.EmployeeID);
        }
Esempio n. 16
0
        /// <summary>
        /// Check the foreign key dal methods.
        /// </summary>
        private void Step_10_FK_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                EmployeePayHistory entity = CreateMockInstance(tm);
                bool result = DataRepository.EmployeePayHistoryProvider.Insert(tm, entity);

                Assert.IsTrue(result, "Could Not Test FK, Insert Failed");

                TList <EmployeePayHistory> t0 = DataRepository.EmployeePayHistoryProvider.GetByEmployeeId(tm, entity.EmployeeId, 0, 10);
            }
        }
        ///<summary>
        ///  Returns a Typed EmployeePayHistory Entity with mock values.
        ///</summary>
        static public EmployeePayHistory CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            EmployeePayHistory mock = EmployeePayHistoryTest.CreateMockInstance_Generated(tm);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);

            // return the modified object
            return(mock);
        }
Esempio n. 18
0
        /// <summary>
        /// Check the indexes dal methods.
        /// </summary>
        private void Step_11_IX_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                EmployeePayHistory entity = CreateMockInstance(tm);
                bool result = DataRepository.EmployeePayHistoryProvider.Insert(tm, entity);

                Assert.IsTrue(result, "Could Not Test IX, Insert Failed");


                EmployeePayHistory t0 = DataRepository.EmployeePayHistoryProvider.GetByEmployeeIdRateChangeDate(tm, entity.EmployeeId, entity.RateChangeDate);
            }
        }
        public virtual EmployeePayHistory MapBOToEF(
            BOEmployeePayHistory bo)
        {
            EmployeePayHistory efEmployeePayHistory = new EmployeePayHistory();

            efEmployeePayHistory.SetProperties(
                bo.BusinessEntityID,
                bo.ModifiedDate,
                bo.PayFrequency,
                bo.Rate,
                bo.RateChangeDate);
            return(efEmployeePayHistory);
        }
Esempio n. 20
0
        /// <summary>
        /// Serialize the mock EmployeePayHistory entity into a temporary file.
        /// </summary>
        private void Step_06_SerializeEntity_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_EmployeePayHistory.xml");

                EntityHelper.SerializeXml(mock, fileName);
                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock not found");

                System.Console.WriteLine("mock correctly serialized to a temporary file.");
            }
        }
        public virtual BOEmployeePayHistory MapEFToBO(
            EmployeePayHistory ef)
        {
            var bo = new BOEmployeePayHistory();

            bo.SetProperties(
                ef.BusinessEntityID,
                ef.ModifiedDate,
                ef.PayFrequency,
                ef.Rate,
                ef.RateChangeDate);
            return(bo);
        }
Esempio n. 22
0
        public async Task ShouldRaiseExceptionDuplicateEmployeePayHistory()
        {
            var payHistory = new EmployeePayHistory
            {
                BusinessEntityID = 1,
                RateChangeDate   = new DateTime(2009, 1, 14),
                Rate             = 150.00M,
                PayFrequency     = PayFrequency.Biweekly
            };

            var exception = await Assert.ThrowsAsync <AdventureWorksUniqueIndexException>(() => _payHistoryRepo.CreatePayHistory(payHistory));

            Assert.Equal("Error: This operation would result in a duplicate employee pay history record.", exception.Message);
        }
Esempio n. 23
0
        public void MapEFToBOList()
        {
            var mapper = new DALEmployeePayHistoryMapper();
            EmployeePayHistory entity = new EmployeePayHistory();

            entity.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, DateTime.Parse("1/1/1987 12:00:00 AM"));

            List <BOEmployeePayHistory> response = mapper.MapEFToBO(new List <EmployeePayHistory>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
        /// <summary>
        /// Make any alterations necessary (i.e. for DB check constraints, special test cases, etc.)
        /// </summary>
        /// <param name="mock">Object to be modified</param>
        static private void SetSpecialTestData(EmployeePayHistory mock)
        {
            //Code your changes to the data object here.
            if (TestUtility.Instance.RandomBoolean())
            {
                mock.PayFrequency = 1;
            }
            else
            {
                mock.PayFrequency = 2;
            }

            mock.Rate = TestUtility.Instance.RandomNumber(7, 200);
        }
 public bool EmployeePayHistoryDelete(EmployeePayHistory employeepayhistory)
 {
     return(Execute <bool>(dal =>
     {
         EmployeePayHistory employeepayhistoryDelete = dal.EmployeePayHistory.Where(x => x.BusinessEntityID == employeepayhistory.BusinessEntityID).FirstOrDefault();
         if (employeepayhistoryDelete != null)
         {
             dal.EmployeePayHistory.DeleteOnSubmit(employeepayhistoryDelete);
             dal.SubmitChanges();
             return true;
         }
         return false;
     }));
 }
Esempio n. 26
0
        /// <summary>
        /// Inserts a mock EmployeePayHistory entity into the database.
        /// </summary>
        private void Step_01_Insert_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                Assert.IsTrue(DataRepository.EmployeePayHistoryProvider.Insert(tm, mock), "Insert failed");

                System.Console.WriteLine("DataRepository.EmployeePayHistoryProvider.Insert(mock):");
                System.Console.WriteLine(mock);

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
Esempio n. 27
0
        public void MapEFToBO()
        {
            var mapper = new DALEmployeePayHistoryMapper();
            EmployeePayHistory entity = new EmployeePayHistory();

            entity.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, DateTime.Parse("1/1/1987 12:00:00 AM"));

            BOEmployeePayHistory response = mapper.MapEFToBO(entity);

            response.BusinessEntityID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PayFrequency.Should().Be(1);
            response.Rate.Should().Be(1m);
            response.RateChangeDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
        }
Esempio n. 28
0
        public async Task ShouldCreateEmployeePayHistoryRecord()
        {
            var payHistory = new EmployeePayHistory
            {
                BusinessEntityID = 1,
                RateChangeDate   = new DateTime(2020, 8, 18),
                Rate             = 150.00M,
                PayFrequency     = PayFrequency.Biweekly
            };

            await _payHistoryRepo.CreatePayHistory(payHistory);

            var result = await _payHistoryRepo.GetPayHistoryByID(payHistory.BusinessEntityID, payHistory.RateChangeDate);

            Assert.NotNull(result);
        }
Esempio n. 29
0
        // PUT api/awbuildversion/5
        public void Put(EmployeePayHistory value)
        {
            var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();

            if (GetActionType.Key != null)
            {
                if (GetActionType.Value.ToList()[0].Equals("DELETE"))
                {
                    adventureWorks_BC.EmployeePayHistoryDelete(value);
                }
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                {
                    adventureWorks_BC.EmployeePayHistoryUpdate(value);
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Converts the entities to dto.
        /// </summary>
        /// <param name="_EmployeePayHistory">The EmployeePayHistory entity</param>
        /// <returns>EmployeePayHistoryDto</returns>
        public EmployeePayHistoryDto ConvertEntitiesToDto(EmployeePayHistory _EmployeePayHistory)
        {
            if (_EmployeePayHistory == null)
            {
                throw new ArgumentNullException("models should not be null");
            }

            var _EmployeePayHistoryDto = new EmployeePayHistoryDto();

            _EmployeePayHistoryDto.EmployeeID     = _EmployeePayHistory.EmployeeID;
            _EmployeePayHistoryDto.RateChangeDate = _EmployeePayHistory.RateChangeDate;
            _EmployeePayHistoryDto.Rate           = _EmployeePayHistory.Rate;
            _EmployeePayHistoryDto.PayFrequency   = _EmployeePayHistory.PayFrequency;
            _EmployeePayHistoryDto.ModifiedDate   = _EmployeePayHistory.ModifiedDate;
            return(_EmployeePayHistoryDto);
        }
Esempio n. 31
0
        /// <summary>
        /// Serialize a EmployeePayHistory collection into a temporary file.
        /// </summary>
        private void Step_08_SerializeCollection_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_EmployeePayHistoryCollection.xml");

                mock = CreateMockInstance(tm);
                TList <EmployeePayHistory> mockCollection = new TList <EmployeePayHistory>();
                mockCollection.Add(mock);

                EntityHelper.SerializeXml(mockCollection, fileName);

                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found");
                System.Console.WriteLine("TList<EmployeePayHistory> correctly serialized to a temporary file.");
            }
        }
Esempio n. 32
0
        public async void Get()
        {
            var mock   = new ServiceMockFacade <IEmployeePayHistoryRepository>();
            var record = new EmployeePayHistory();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new EmployeePayHistoryService(mock.LoggerMock.Object,
                                                        mock.RepositoryMock.Object,
                                                        mock.ModelValidatorMockFactory.EmployeePayHistoryModelValidatorMock.Object,
                                                        mock.BOLMapperMockFactory.BOLEmployeePayHistoryMapperMock,
                                                        mock.DALMapperMockFactory.DALEmployeePayHistoryMapperMock);

            ApiEmployeePayHistoryResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Esempio n. 33
0
 /// <summary>
 /// Create a new EmployeePayHistory object.
 /// </summary>
 /// <param name="employeeID">Initial value of EmployeeID.</param>
 /// <param name="rateChangeDate">Initial value of RateChangeDate.</param>
 /// <param name="rate">Initial value of Rate.</param>
 /// <param name="payFrequency">Initial value of PayFrequency.</param>
 /// <param name="modifiedDate">Initial value of ModifiedDate.</param>
 public static EmployeePayHistory CreateEmployeePayHistory(int employeeID, global::System.DateTime rateChangeDate, decimal rate, byte payFrequency, global::System.DateTime modifiedDate)
 {
     EmployeePayHistory employeePayHistory = new EmployeePayHistory();
     employeePayHistory.EmployeeID = employeeID;
     employeePayHistory.RateChangeDate = rateChangeDate;
     employeePayHistory.Rate = rate;
     employeePayHistory.PayFrequency = payFrequency;
     employeePayHistory.ModifiedDate = modifiedDate;
     return employeePayHistory;
 }
 // POST api/awbuildversion
 public void Post(EmployeePayHistory value)
 {
     adventureWorks_BC.EmployeePayHistoryAdd(value);
 }
Esempio n. 35
0
 /// <summary>
 /// There are no comments for EmployeePayHistory in the schema.
 /// </summary>
 public void AddToEmployeePayHistory(EmployeePayHistory employeePayHistory)
 {
     base.AddObject("EmployeePayHistory", employeePayHistory);
 }