protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);

            IConfiguration configuration = new BasicConfiguration();
            var container = configuration.Container;

            _ingredientRepository = new IngredientRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());

            _ingredientAdviceRepository = new Repository<IngredientAdvice>(GetNewDataContext());
            _ingredientAdviceDomainService = new IngredientAdviceDomainService(_ingredientRepository,
                                                                               _ingredientAdviceRepository,
                                                                               GetNewDataContext());

           

            _mentor = MentorBuilder.BuildMentor();
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = SemaphoreBuilder.BuildRedSemaphore();
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = SemaphoreBuilder.BuildGreenSemaphore();
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            _ingredient = IngredientBuilder.BuildIngredient();
            _ingredientRepository.Add(_ingredient);
            _ingredientRepository.Persist();

            base.Before_each_spec();
        }
        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);
            

            var ingredient1 = new Ingredient {IngredientName = "Hop", LastUpdated = DateTime.Now};
            var ingredient2 = new Ingredient {IngredientName = "Malt", LastUpdated = DateTime.Now};
            var ingredient3 = new Ingredient {IngredientName = "Water", LastUpdated = DateTime.Now };

            _ingredientRepository = new Repository<Ingredient>(GetNewDataContext());
            _ingredientRepository.Add(ingredient1);
            _ingredientRepository.Add(ingredient2);
            _ingredientRepository.Add(ingredient3);
            _ingredientRepository.Persist();

            _product = ProductBuilder.BuildProduct();
            _product.AddIngredient(ingredient1);
            _product.AddIngredient(ingredient2);
            _product.AddIngredient(ingredient3);
            _productRepository = new Repository<Product>(GetNewDataContext());
            _productRepository.Add(_product);
            _productRepository.Persist();

            base.Before_each_spec();
        }
        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);
            _productBuilder = new ProductBuilder();

            _productAdviceRepository = new Repository<ProductAdvice>(GetNewDataContext());
            _productAdviceDomainService =
                new ProductAdviceDomainService(new ProductRepository(GetNewDataContext()),
                                                   _productAdviceRepository, GetNewDataContext());

            _productRepository = new ProductRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());     

            _mentor = new Mentor
                          {
                MentorName = "Consumentor"
            };
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = new Semaphore
                             {
                ColorName = "Red",
                Value = -1
            };
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = new Semaphore
                                  {
                                      ColorName = "Green",
                                      Value = 1
                                  };
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            _product = ProductBuilder.BuildProduct();
            _productRepository.Add(_product);
            _productRepository.Persist();

            base.Before_each_spec();
        }
Example #4
0
        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);

            _ingredientAdviceRepository = new Repository<IngredientAdvice>(GetNewDataContext());

            _ingredientRepository = new IngredientRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());

            _mentor = MentorBuilder.BuildMentor();
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = SemaphoreBuilder.BuildRedSemaphore();
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = SemaphoreBuilder.BuildGreenSemaphore();
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            base.Before_each_spec();
        }
        public PushModule(IRepository repository)
        {
            _log = LogManager.GetLogger(GetType());
            _log.Info("In Fake Push API....");

            this.RequiresAuthentication();

            Get["api/push"] = _ => Response.AsJson(new {Hello = "welcome to receiving stuff pushed from all over..."});

            Get["api/push/received/all"] = _ =>
            {
                var transations = repository.GetAll<Transaction>().ToList();
                var model = transations.Any()
                    ? transations.Select(
                        s =>
                            new TransactionDto(s.PackageId, s.UserId, s.Username, s.ContractId, s.AccountNumber, s.ResponseDate, s.RequestId, s.Report,
                                s.HasResponse)).OrderByDescending(o => o.ResponseDate).ToList()
                    : new List<TransactionDto>();
                return View["Push/Received", model];
            };

            Get["api/push/received/errors"] = _ =>
            {
                var errors = repository.GetAll<Error>().ToList();
                var model = errors.Any() ? errors.ToList() : new List<Error>();
                return View["Push/Errors", model];
            };

            Post["api/push"] = _ =>
            {
                _log.Info("Importing push item from POST");

                try
                {
                    var model = this.Bind<Transaction>();

                    if (model == null)
                    {
                        _log.Error("Could not bind to package transaction recived from push");
                        repository.Persist(new Error(Guid.NewGuid(), "Could not bind to package transactions received from push", "Receive Pushed Item", DateTime.Now));
                        return HttpStatusCode.BadRequest;
                    }

                    repository.Persist(model);
                }
                catch (Exception ex)
                {
                    repository.Persist(new Error(Guid.NewGuid(), ex.Message, "Receive Pushed Item", DateTime.Now));
                    return HttpStatusCode.BadRequest;
                }
               

                return HttpStatusCode.OK;
            };

            Put["api/push"] = _ =>
            {
                _log.Info("Importing push item from PUT");
                return HttpStatusCode.OK;
            };
        }