Esempio n. 1
0
        public void ShouldGetWaitingProduceOrdersForPlanet()
        {
            ProduceOrderModule module;

            ProduceOrder[] results;
            IDatabase      database;

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

            module  = new ProduceOrderModule(NullLogger.Instance, database);
            results = module.GetWaitingProduceOrders(1);
            Assert.IsNotNull(results);
            Assert.AreEqual(3, results.Length);
            for (int t = 0; t < 3; t++)
            {
                Assert.IsNotNull(results[t]);
                Assert.AreEqual(t + 1, results[t].ProduceOrderID);
            }
        }
Esempio n. 2
0
        public void ShouldNotGetWaitingProduceOrdersForPlanetAndLogError()
        {
            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.GetWaitingProduceOrders(1));
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName)));
        }