예제 #1
0
        private static async void Update(long id)
        {
            var item  = client.GetById(id).Result;
            var nitem = new Employee();

            Console.Write($"Input FirstName ({item.FirstName}): ");
            nitem.FirstName = Console.ReadLine();
            Console.Write($"Input LastName ({item.LastName}): ");
            nitem.LastName = Console.ReadLine();
            Console.Write($"Input DateOfBirth ({item.DateOfBirth.ToShortDateString()}): ");
            nitem.DateOfBirth = DateTime.Parse(Console.ReadLine());
            Console.Write($"Input PhoneNumber ({item.PhoneNumber}): ");
            nitem.PhoneNumber = Console.ReadLine();
            Console.Write($"Input Email ({item.Email}): ");
            nitem.Email = Console.ReadLine();

            //не знаю, как сделать по-другому, пока так.
            logger.Info("Record update. It's id=" + id + "\r\n Updates:\r\n" +
                        (item.FirstName != nitem.FirstName ? "FirstName:" + item.FirstName + ">" + nitem.FirstName + "\r\n" : "") +
                        (item.LastName != nitem.LastName ? "LastName:" + item.LastName + ">" + nitem.LastName + "\r\n" : "") +
                        (item.DateOfBirth != nitem.DateOfBirth ? "DateOfBirth:" + item.DateOfBirth + ">" + nitem.DateOfBirth + "\r\n" : "") +
                        (item.PhoneNumber != nitem.PhoneNumber ? "PhoneNumber:" + item.PhoneNumber + ">" + nitem.PhoneNumber + "\r\n" : "") +
                        (item.Email != nitem.Email ? "Email:" + item.Email + ">" + nitem.Email + "\r\n" : "")
                        );
            await client.Update(id, nitem);
        }
예제 #2
0
        public void Update_Should_Update_A_Test()
        {
            _repository
            .Setup(it => it.Update(It.IsAny <Int32>(), It.IsAny <Int32?>(), It.IsAny <Int32?>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <Boolean>(), It.IsAny <Int32>()))
            .Callback <Int32, Int32?, Int32?, String, String, Boolean, Int32>((testTypeId, projectId, groupId, name, testValue, isActive, id) =>
            {
                var tTest        = _repositoryList.Find(x => x.Id == id);
                tTest.TestTypeId = testTypeId;
                tTest.ProjectId  = projectId;
                tTest.GroupId    = groupId;
                tTest.Name       = name;
                tTest.TestValue  = testValue;
                tTest.IsActive   = isActive;
            });
            var tempTest = _repositoryList.Find(x => x.Id == id);
            var testTest = new Test {
                Id         = tempTest.Id,
                TestTypeId = tempTest.TestTypeId,
                ProjectId  = tempTest.ProjectId,
                GroupId    = tempTest.GroupId,
                Name       = tempTest.Name,
                TestValue  = tempTest.TestValue,
                IsActive   = tempTest.IsActive
            };

            //TODO change something on testTest
            //testTest.oldValue = newValue;
            _target.Update(testTest);
            //Assert.AreEqual(newValue, _repositoryList.Find(x => x.Id==1).oldValue);
            //TODO fail until we update the test above
            Assert.Fail();
        }