コード例 #1
0
        public void GetAllLogOk()
        {
            Guid id  = Guid.NewGuid();
            Log  log = new Log {
                Id   = id,
                Date = DateTime.Now
            };
            var            context     = LogContextFactory.GetMemoryContext(Guid.NewGuid().ToString());
            ILogRepository logRepo     = new LogRepository(context);
            LoggerLogic    loggerLogic = new LoggerLogic(logRepo);

            loggerLogic.Create(log);
            var logs = loggerLogic.GetAll().ToList();

            Assert.AreEqual(logs[0].Id, id);
        }
コード例 #2
0
        public void CreateLogWithMockOk()
        {
            Guid id  = Guid.NewGuid();
            Log  log = new Log {
                Id   = id,
                Date = DateTime.Now
            };
            var mock = new Mock <ILogRepository>(MockBehavior.Strict);

            mock.Setup(m => m.Add(It.IsAny <Log>()));
            mock.Setup(m => m.Save());
            LoggerLogic loggerLogic = new LoggerLogic(mock.Object);

            loggerLogic.Create(log);

            mock.VerifyAll();
        }
コード例 #3
0
        static Dependencies()
        {
            var roleDaoSet = ConfigurationManager.AppSettings["roleDaoSet"];

            switch (roleDaoSet)
            {
            case "1":
                roleDao = new RoleDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(roleDaoSet)}!");
            }

            var userDaoSet = ConfigurationManager.AppSettings["userDaoSet"];

            switch (userDaoSet)
            {
            case "1":
                userDao = new UserDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(userDaoSet)}!");
            }

            var customerDaoSet = ConfigurationManager.AppSettings["customerDaoSet"];

            switch (customerDaoSet)
            {
            case "1":
                productDao = new ProductDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(customerDaoSet)}!");
            }

            var productDaoSet = ConfigurationManager.AppSettings["productDaoSet"];

            switch (productDaoSet)
            {
            case "1":
                customerDao = new CustomerDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(productDaoSet)}!");
            }

            var orderDaoSet = ConfigurationManager.AppSettings["orderDaoSet"];

            switch (orderDaoSet)
            {
            case "1":
                orderDao = new OrderDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(orderDaoSet)}!");
            }

            var orderProductDaoSet = ConfigurationManager.AppSettings["orderProductDaoSet"];

            switch (orderProductDaoSet)
            {
            case "1":
                orderProductDao = new OrderProductDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(orderProductDaoSet)}!");
            }

            var managerDaoSet = ConfigurationManager.AppSettings["managerDaoSet"];

            switch (managerDaoSet)
            {
            case "1":
                managerDao = new ManagerDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(managerDaoSet)}!");
            }

            var loggerDaoSet = ConfigurationManager.AppSettings["loggerDaoSet"];

            switch (loggerDaoSet)
            {
            case "2":
                loggerDao = new LoggerDaoFile();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(loggerDaoSet)}!");
            }

            var feedbackDaoSet = ConfigurationManager.AppSettings["feedbackDaoSet"];

            switch (feedbackDaoSet)
            {
            case "1":
                feedbackDao = new FeedbackDaoDb();
                break;

            default:
                throw new ConfigurationErrorsException($"Can't find settings for {nameof(feedbackDaoSet)}!");
            }

            RoleLogic         = new RoleLogic(roleDao, loggerDao);
            UserLogic         = new UserLogic(userDao, loggerDao);
            CustomerLogic     = new CustomerLogic(customerDao, loggerDao);
            ProductLogic      = new ProductLogic(productDao, loggerDao);
            OrderLogic        = new OrderLogic(orderDao, loggerDao);
            OrderProductLogic = new OrderProductLogic(orderProductDao, loggerDao);
            ManagerLogic      = new ManagerLogic(managerDao, loggerDao);
            LoggerLogic       = new LoggerLogic(loggerDao);
            FeedbackLogic     = new FeedbackLogic(feedbackDao, loggerDao);
        }