Ejemplo n.º 1
0
        public void ShouldNotGetProduceOrderAndLogError()
        {
            ProduceOrderModule module;
            MemoryLogger       logger;
            IDatabase          database;

            logger = new MemoryLogger();

            database = Substitute.For <IDatabase>();
            database.Execute <ProduceOrder>(Arg.Any <ISelect>()).Returns((x) => { throw new Exception(); });

            module = new ProduceOrderModule(logger, database);
            Assert.ThrowsException <PIODataException>(() => module.GetProduceOrder(1));
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName)));
        }
Ejemplo n.º 2
0
        public void ShouldGetProduceOrder()
        {
            ProduceOrderModule module;
            ProduceOrder       result;
            IDatabase          database;

            database = Substitute.For <IDatabase>();
            database.Execute <ProduceOrder>(Arg.Any <ISelect>()).Returns(new ProduceOrder[] { new ProduceOrder()
                                                                                              {
                                                                                                  ProduceOrderID = 1
                                                                                              } });

            module = new ProduceOrderModule(NullLogger.Instance, database);
            result = module.GetProduceOrder(1);
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ProduceOrderID);
        }