Beispiel #1
0
        public void CheckIfGetResultIsValid()
        {
            ClassForDataRepositoryTest testModel = new ClassForDataRepositoryTest();
            DataRepository <ClassForDataRepositoryTest> dataRepository = CreateDataRepository();

            dataRepository.DbContext.Add(testModel);
            dataRepository.DbContext.SaveChanges();
            int testModelId = testModel.Id;
            ClassForDataRepositoryTest addedModel = dataRepository.Get(testModelId);

            Assert.NotNull(addedModel);
        }
Beispiel #2
0
        public void CheckIfModelIsAdded()
        {
            ClassForDataRepositoryTest testModel = new ClassForDataRepositoryTest();
            DataRepository <ClassForDataRepositoryTest> dataRepository = CreateDataRepository();

            dataRepository.Add(testModel);
            int testModelId = testModel.Id;
            ClassForDataRepositoryTest addedModel = dataRepository.DbContext.Find(
                typeof(ClassForDataRepositoryTest),
                new object[] { testModelId }
                ) as ClassForDataRepositoryTest;

            Assert.NotNull(addedModel);
        }
Beispiel #3
0
        public void CheckIfModelIsUpdated()
        {
            ClassForDataRepositoryTest testModel = new ClassForDataRepositoryTest();
            DataRepository <ClassForDataRepositoryTest> dataRepository = CreateDataRepository();

            dataRepository.Add(testModel);
            int testModelId = testModel.Id;

            testModel.Name = "test name";
            dataRepository.Update(testModel);
            ClassForDataRepositoryTest updatedModel = dataRepository.DbContext.Find(
                typeof(ClassForDataRepositoryTest),
                new object[] { testModelId }
                ) as ClassForDataRepositoryTest;

            Assert.Equal(testModel.Name, updatedModel.Name);
        }