public void EditTest()
        {
            CreateContext();
            DefaultController <ObjectMappingForTest> defaultController = new DefaultController <ObjectMappingForTest>(new FakeLogger(),
                                                                                                                      new FetchDomainData <ObjectMappingForTest>(_uow),
                                                                                                                      new HandlerCRUD <ObjectMappingForTest, AddParamOfCRUDOperation <ObjectMappingForTest> >(new RepositoryAddItem <ObjectMappingForTest, AddParamOfCRUDOperation <ObjectMappingForTest> >(_uow, context)),
                                                                                                                      new HandlerCRUD <ObjectMappingForTest, EditParamOfCRUDOperation <ObjectMappingForTest> >(new RepositoryEditItem <ObjectMappingForTest, EditParamOfCRUDOperation <ObjectMappingForTest> >(_uow, context)),
                                                                                                                      new HandlerCRUD <ObjectMappingForTest, DeleteParamOfCRUDOperation <ObjectMappingForTest> >(new RepositoryDeleteItem <ObjectMappingForTest, DeleteParamOfCRUDOperation <ObjectMappingForTest> >(_uow, context)));

            //Проверка редактирования без ID.Будет ошибка, так как нет идентификатора записи
            EditParamOfCRUDOperation <ObjectMappingForTest> paramQueryAdd = new EditParamOfCRUDOperation <ObjectMappingForTest>();

            paramQueryAdd.Item = new ObjectMappingForTest()
            {
                IntValue  = 1,
                IntValue2 = 1,
                StrValue  = "1"
            };
            var exArgumentException = Assert.ThrowsExceptionAsync <ArgumentException>(() => defaultController.Edit(paramQueryAdd));

            Assert.AreEqual("Объект не найден в БД для изменения.", exArgumentException.Result.Message);

            //Проверка успешного изменения записи
            paramQueryAdd.Item = new ObjectMappingForTest()
            {
                Id        = 3,
                IntValue  = 1,
                IntValue2 = 1,
                StrValue  = "1"
            };
            JsonResult resultAdd = defaultController.Edit(paramQueryAdd).Result;
            BaseResultType <PrepareItemResult <ObjectMappingForTest> > resultSuccessQuery = (BaseResultType <PrepareItemResult <ObjectMappingForTest> >)resultAdd.Value;

            Assert.AreEqual(ResultStatus.Success, resultSuccessQuery.Status);
            Assert.IsNotNull(resultSuccessQuery.Data.Item);

            Assert.IsInstanceOfType(resultSuccessQuery.Data.Item, typeof(ObjectMappingForTest), "Вернулся тип объекта не ObjectMappingForTest после сохранения этого объекта.");
            Assert.AreEqual(1, ((ObjectMappingForTest)resultSuccessQuery.Data.Item).IntValue);
            Assert.AreEqual(1, ((ObjectMappingForTest)resultSuccessQuery.Data.Item).IntValue2);
            Assert.AreEqual("1", ((ObjectMappingForTest)resultSuccessQuery.Data.Item).StrValue);
            Assert.AreEqual(3, ((ObjectMappingForTest)resultSuccessQuery.Data.Item).Id);


            //Проверка запроса из БД, что запись не добавилась
            JsonResult result = defaultController.GetAsync(new FetchDataParameters()
            {
                CountOnPage = 10, PageNumber = 1
            }).Result;
            BaseResultType <ResultFetchData <ObjectMappingForTest> > fetchDataResultQuery = (BaseResultType <ResultFetchData <ObjectMappingForTest> >)result.Value;

            Assert.AreEqual(ResultStatus.Success, fetchDataResultQuery.Status);
            Assert.AreEqual(3, fetchDataResultQuery.Data.TotalCountRows);

            ObjectMappingForTest itemFromDB = fetchDataResultQuery.Data.Items[2];

            Assert.AreEqual(1, itemFromDB.IntValue);
            Assert.AreEqual(1, itemFromDB.IntValue2);
            Assert.AreEqual("1", itemFromDB.StrValue);
            Assert.AreEqual(3, itemFromDB.Id);
        }
        public void DeleteTest()
        {
            CreateContext();
            DefaultController <ObjectMappingForTest> defaultController = new DefaultController <ObjectMappingForTest>(new FakeLogger(),
                                                                                                                      new FetchDomainData <ObjectMappingForTest>(_uow),
                                                                                                                      new HandlerCRUD <ObjectMappingForTest, AddParamOfCRUDOperation <ObjectMappingForTest> >(new RepositoryAddItem <ObjectMappingForTest, AddParamOfCRUDOperation <ObjectMappingForTest> >(_uow, context)),
                                                                                                                      new HandlerCRUD <ObjectMappingForTest, EditParamOfCRUDOperation <ObjectMappingForTest> >(new RepositoryEditItem <ObjectMappingForTest, EditParamOfCRUDOperation <ObjectMappingForTest> >(_uow, context)),
                                                                                                                      new HandlerCRUD <ObjectMappingForTest, DeleteParamOfCRUDOperation <ObjectMappingForTest> >(new RepositoryDeleteItem <ObjectMappingForTest, DeleteParamOfCRUDOperation <ObjectMappingForTest> >(_uow, context)));

            var exArgumentException = Assert.ThrowsExceptionAsync <ArgumentException>(() => defaultController.Delete(10));

            Assert.AreEqual("Записи для удаления не существует.", exArgumentException.Result.Message);

            //Проверка успешного удаления записи
            long       idDelete  = 3;
            JsonResult resultAdd = defaultController.Delete(idDelete).Result;
            BaseResultType <PrepareItemResult <ObjectMappingForTest> > resultSuccessQuery = (BaseResultType <PrepareItemResult <ObjectMappingForTest> >)resultAdd.Value;

            Assert.AreEqual(ResultStatus.Success, resultSuccessQuery.Status);
            Assert.IsNotNull(resultSuccessQuery.Data.Item);

            //Проверка запроса из БД, что запись удалилась
            JsonResult result = defaultController.GetAsync(new FetchDataParameters()
            {
                CountOnPage = 10, PageNumber = 1
            }).Result;
            BaseResultType <ResultFetchData <ObjectMappingForTest> > fetchDataResultQuery = (BaseResultType <ResultFetchData <ObjectMappingForTest> >)result.Value;

            Assert.AreEqual(ResultStatus.Success, fetchDataResultQuery.Status);
            Assert.AreEqual(2, fetchDataResultQuery.Data.TotalCountRows);

            Assert.AreEqual(2, fetchDataResultQuery.Data.Items.Count);
            Assert.IsFalse(fetchDataResultQuery.Data.Items.Any(x => x.Id == idDelete));
        }
        public void GetAsyncTest()
        {
            CreateContext();
            DefaultController <ObjectMappingForTest> defaultController = new DefaultController <ObjectMappingForTest>(new FakeLogger(), new FetchDomainData <ObjectMappingForTest>(_uow), null, null, null);

            //Выборка первой страницы с дефолтным размером стриницы
            JsonResult result = defaultController.GetAsync(null).Result;
            BaseResultType <ResultFetchData <ObjectMappingForTest> > fetchDataResultQuery = (BaseResultType <ResultFetchData <ObjectMappingForTest> >)result.Value;

            Assert.AreEqual(ResultStatus.Success, fetchDataResultQuery.Status);
            Assert.AreEqual(3, fetchDataResultQuery.Data.TotalCountRows);
            Assert.AreEqual(3, fetchDataResultQuery.Data.Items.Count);

            //Проверка выборки первой страницы
            result = defaultController.GetAsync(new FetchDataParameters()
            {
                CountOnPage = 1
            }).Result;
            fetchDataResultQuery = (BaseResultType <ResultFetchData <ObjectMappingForTest> >)result.Value;
            Assert.AreEqual(ResultStatus.Success, fetchDataResultQuery.Status);
            Assert.AreEqual(3, fetchDataResultQuery.Data.TotalCountRows, "Общий подсчет записей при запросе не работает.");
            Assert.AreEqual(1, fetchDataResultQuery.Data.Items.Count);
            Assert.AreEqual(1, fetchDataResultQuery.Data.Items[0].Id);
            Assert.AreEqual(1, fetchDataResultQuery.Data.PageNumber);
            //Проверка выборки второй страницы
            result = defaultController.GetAsync(new FetchDataParameters()
            {
                CountOnPage = 1, PageNumber = 2
            }).Result;
            fetchDataResultQuery = (BaseResultType <ResultFetchData <ObjectMappingForTest> >)result.Value;
            Assert.AreEqual(ResultStatus.Success, fetchDataResultQuery.Status);
            Assert.AreEqual(3, fetchDataResultQuery.Data.TotalCountRows);
            Assert.AreEqual(1, fetchDataResultQuery.Data.Items.Count);
            Assert.AreEqual(2, fetchDataResultQuery.Data.Items[0].Id);
            Assert.AreEqual(2, fetchDataResultQuery.Data.PageNumber);
        }
        public void AddTest()
        {
            CreateContext();
            DefaultController <ObjectMappingForTest> defaultController = new DefaultController <ObjectMappingForTest>(new FakeLogger(),
                                                                                                                      new FetchDomainData <ObjectMappingForTest>(_uow),
                                                                                                                      new HandlerCRUD <ObjectMappingForTest, AddParamOfCRUDOperation <ObjectMappingForTest> >(new RepositoryAddItem <ObjectMappingForTest, AddParamOfCRUDOperation <ObjectMappingForTest> >(_uow, context)),
                                                                                                                      new HandlerCRUD <ObjectMappingForTest, EditParamOfCRUDOperation <ObjectMappingForTest> >(new RepositoryEditItem <ObjectMappingForTest, EditParamOfCRUDOperation <ObjectMappingForTest> >(_uow, context)),
                                                                                                                      new HandlerCRUD <ObjectMappingForTest, DeleteParamOfCRUDOperation <ObjectMappingForTest> >(new RepositoryDeleteItem <ObjectMappingForTest, DeleteParamOfCRUDOperation <ObjectMappingForTest> >(_uow, context)));

            AddParamOfCRUDOperation <ObjectMappingForTest> paramQueryAdd = new AddParamOfCRUDOperation <ObjectMappingForTest>();

            paramQueryAdd.Item = new ObjectMappingForTest()
            {
                IntValue = 1, IntValue2 = 1, StrValue = "1"
            };
            JsonResult resultAdd = defaultController.Add(paramQueryAdd).Result;
            BaseResultType <PrepareItemResult <ObjectMappingForTest> > resultSuccessQuery = ((BaseResultType <PrepareItemResult <ObjectMappingForTest> >)resultAdd.Value);

            Assert.AreEqual(ResultStatus.Success, resultSuccessQuery.Status);
            Assert.IsNotNull(resultSuccessQuery.Data);

            Assert.IsInstanceOfType(resultSuccessQuery.Data, typeof(PrepareItemResult <ObjectMappingForTest>), "Вернулся тип объекта не ObjectMappingForTest после сохранения этого объекта.");
            Assert.AreEqual(1, ((ObjectMappingForTest)resultSuccessQuery.Data.Item).IntValue);
            Assert.AreEqual(1, ((ObjectMappingForTest)resultSuccessQuery.Data.Item).IntValue2);
            Assert.AreEqual("1", ((ObjectMappingForTest)resultSuccessQuery.Data.Item).StrValue);
            Assert.AreEqual(4, ((ObjectMappingForTest)resultSuccessQuery.Data.Item).Id);

            //Проверка запроса из БД, что запись добавилась
            JsonResult result = defaultController.GetAsync(new FetchDataParameters()
            {
                CountOnPage = 10, PageNumber = 1
            }).Result;
            BaseResultType <ResultFetchData <ObjectMappingForTest> > fetchDataResultQuery = (BaseResultType <ResultFetchData <ObjectMappingForTest> >)result.Value;

            Assert.AreEqual(ResultStatus.Success, fetchDataResultQuery.Status);
            Assert.AreEqual(4, fetchDataResultQuery.Data.TotalCountRows);
        }