public void TestLoadSearchOportoMock() { Mocker mocker = new Mocker(typeof(IWeatherWebApi)); mocker .When("Search") .With("oporto") .Return(new LocationInfo[] { null, null, null, null, null, new LocationInfo("Cuba", "", 0, 0) }); IWeatherWebApi api = (IWeatherWebApi)mocker.Create(); LocationInfo[] locals = api.Search("oporto"); Assert.AreEqual("Cuba", locals[5].Country); Assert.AreEqual("", locals[5].Region); Assert.AreEqual(0, locals[5].Latitude); Assert.AreEqual(0, locals[5].Longitude); }
public void TestLoadSearchOportoOnMock() { Mocker mocker = new Mocker(typeof(IWeatherWebApi)); mocker .When("Search") .With("oporto") .Return(new LocationInfo[] { null, null, null, null, null, new LocationInfo("Cuba", "", 0, 0) }); mocker .When("Dispose").Then(() => { }).With(); using (IWeatherWebApi api = (IWeatherWebApi)mocker.Create()) { IEnumerable <LocationInfo> locals = api.Search("oporto"); Assert.AreEqual(6, locals.Count()); Assert.AreEqual("Cuba", locals.ElementAt(5).Country); } }