public async Task Get_取得全部資料() { using (var dbContext = new SampledbContext(this.Options)) { var sut = new WifiSpotRepository(dbContext); // act var actual = await sut.GetAll(); // assert actual.Any().Should().BeTrue(); } }
public async Task GetById_輸入資料不存在的id_應回傳null() { var id = "9CC727EC-8EBF-46EA-BEB5-48EB603F4523"; using (var dbContext = new SampledbContext(this.Options)) { var sut = new WifiSpotRepository(dbContext); // act var actual = await sut.GetById(id); // assert actual.Should().BeNull(); } }
public async Task GetById_輸入資料存在的id_應回傳對映id的資料() { var id = "ZZZITWF000159"; var expectedSpotName = "新北市淡水區公所"; using (var dbContext = new SampledbContext(this.Options)) { var sut = new WifiSpotRepository(dbContext); // act var actual = await sut.GetById(id); // assert actual.Should().NotBeNull(); actual.Id.Should().Be(id); actual.SpotName.Should().Be(expectedSpotName); } }
public WifiSpotRepository(SampledbContext dbContext) { this.DbContext = dbContext; }