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); }
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); }
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); }