public void ReturnAllSensorTypes_When_Invoked() { //Arrange var contextOptions = new DbContextOptionsBuilder <SmartDormitoryDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; using (var arrangeContext = new SmartDormitoryDbContext(contextOptions)) { var sensorType = new SensorTypes { IsDeleted = false, Type = "testType", CreatedOn = DateTime.Now, }; arrangeContext.SensorTypes.Add(sensorType); arrangeContext.SaveChanges(); } // Act && Asert using (var assertContext = new SmartDormitoryDbContext(contextOptions)) { var sensorService = new SensorService(assertContext); var allSensorTypes = sensorService.GetAllTypes().ToList(); Assert.AreEqual(1, allSensorTypes.Count); } }
public void ReturnEmptyCollection_When_SensorTypesDB_IsEmpty() { //Arrange var contextOptions = new DbContextOptionsBuilder <SmartDormitoryDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; // Act && Asert using (var assertContext = new SmartDormitoryDbContext(contextOptions)) { var sensorService = new SensorService(assertContext); var allSensorTypes = sensorService.GetAllTypes().ToList(); Assert.AreEqual(0, allSensorTypes.Count); } }