public async Task GetAllLoadOptions() { var rep = CreateMock <IDynItemController>(); var ctrl = new LoadOptionsManager(); rep.GetAll(typeof(LoadOptions)). Returns(new[] { new DynItem { ItemId = 1, Name = "Entry1" } }); rep.Create(1).Returns(new LoadOptions { SettingName = "Entry1", Id = 1, FileName = "HA" }); var all = await ctrl.GetAll(); all.Count().Should().Be(1); all.FirstOrDefault().Id.Should().Be(1); all.FirstOrDefault().SettingName.Should().Be("Entry1"); all.FirstOrDefault().FileName.Should().Be("HA"); }
public async Task GetLoadOptionsNull() { var rep = CreateMock <IDynItemController>(); var ctrl = new LoadOptionsManager(rep); rep.Create(1).Returns(new LoadOptions { SettingName = "Entry1", Id = 1, FileName = "HA" }); var all = await ctrl.Get(2); all.Should().BeNull(); }
public async Task DeleteLoadOptions() { var rep = CreateMock <IDynItemController>(); var ctrl = new LoadOptionsManager(rep); var opt = new LoadOptions { SettingName = "Entry1", Id = 1, FileName = "HA" }; await ctrl.Delete(opt).ConfigureAwait(false); await rep.Received().Delete(Arg.Is <int>(x => x == 1)); }
public async Task UpdateLoadOptions() { var rep = CreateMock <IDynItemController>(); var ctrl = new LoadOptionsManager(rep); var opt = new LoadOptions { SettingName = "Entry1", Id = 1, FileName = "HA" }; await ctrl.Update(opt); await rep.Received().Save(Arg.Is <int>(x => x == 1), Arg.Is <string>(x => x == "Entry1"), Arg.Is <LoadOptions>(x => x.SettingName == "Entry1" && x.FileName == "HA")); }