public void ShouldNotCreateProduceOrderAndLogError() { ProduceOrderModule module; MemoryLogger logger; IDatabase database; logger = new MemoryLogger(); database = Substitute.For <IDatabase>(); database.When(x => x.Execute(Arg.Any <IQuery[]>())).Do(x => { throw new Exception(); }); module = new ProduceOrderModule(logger, database); Assert.ThrowsException <PIODataException>(() => module.CreateProduceOrder(1, 2)); Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName))); }
public void ShouldCreateProduceOrder() { ProduceOrderModule module; ProduceOrder result; IDatabase database; int inserted = 0; database = Substitute.For <IDatabase>(); database.When(x => x.Execute(Arg.Any <IQuery[]>())).Do(x => inserted++); module = new ProduceOrderModule(NullLogger.Instance, database); result = module.CreateProduceOrder(1, 2); Assert.IsNotNull(result); Assert.AreEqual(2, inserted); }