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();
        }
Example #3
0
 private static Setting InitializeSetting(string settingName, IRepository repository)
 {
     var setting = new Setting { Name = settingName.Encrypt() };
     repository.Add<Setting>(setting);
     repository.Save();
     return setting;
 }
Example #4
0
        static void Main(string[] args)
        {
            var builder = new ContainerBuilder();

            builder.RegisterType<Customer>().As<ICustomer>();
            builder.RegisterType<LineItem>().As<ILineItem>();
            builder.RegisterType<Order>().As<IOrder>();
            builder.RegisterType<Product>().As<IProduct>();

            Container = builder.Build();

            _customerRepo = new Repository<Customer>();
            _customerRepo.Add(new Customer { FirstName = "Chris", LastName = "Cais" });
            _customerRepo.Add(new Customer { FirstName = "James", LastName = "Harden" });
            _customerRepo.Save();
        }
Example #5
0
        public PSTutorialFlags(account account, IRepository<character_tutorial> characterTutorials)
            : base(WorldOpcodes.SMSG_TUTORIAL_FLAGS)
        {
            character_tutorial characterTutorial = characterTutorials.SingleOrDefault(ct => ct.account == account.id);

            if (characterTutorial == null)
            {
                characterTutorial = new character_tutorial()
                                        {
                                            account = account.id,
                                            tut0 = 0,
                                            tut1 = 0,
                                            tut2 = 0,
                                            tut3 = 0,
                                            tut4 = 0,
                                            tut5 = 0,
                                            tut6 = 0,
                                            tut7 = 0
                                        };
                characterTutorials.Add(characterTutorial);
            }

            this.Write((byte)characterTutorial.tut0);
            this.Write((byte)characterTutorial.tut1);
            this.Write((byte)characterTutorial.tut2);
            this.Write((byte)characterTutorial.tut3);
            this.Write((byte)characterTutorial.tut4);
            this.Write((byte)characterTutorial.tut5);
            this.Write((byte)characterTutorial.tut6);
            this.Write((byte)characterTutorial.tut7);
        }
        public void Add(BusinessObjects.GroupRelation entity)
        {
            //Add GroupRelation
            using (_GroupRelationRepository = new GenericRepository<DAL.DataEntities.GroupRelation>())
            {
                _GroupRelationRepository.Add((DAL.DataEntities.GroupRelation)entity.InnerEntity);
                _GroupRelationRepository.SaveChanges();
            }

            //Add GroupRelations_To_Features
            using (_GroupRelationsToFeaturesRepository = new GenericRepository<DAL.DataEntities.GroupRelation_To_Feature>())
            {

                foreach (int childFeatureID in entity.ChildFeatureIDs)
                {
                    DAL.DataEntities.GroupRelation_To_Feature grToFeature = new DAL.DataEntities.GroupRelation_To_Feature();
                    grToFeature.GroupRelationID = entity.ID;
                    grToFeature.ParentFeatureID = entity.ParentFeatureID;
                    grToFeature.ChildFeatureID = childFeatureID;

                    _GroupRelationsToFeaturesRepository.Add(grToFeature);
                }

                _GroupRelationsToFeaturesRepository.SaveChanges();
            }
        }
        public void Add_Should_Result_In_Proper_Total_Items(IRepository<Contact, string> repository)
        {
            repository.Add(new Contact { Name = "Test User" });

            var result = repository.GetAll();
            result.Count().ShouldEqual(1);
        }
Example #8
0
 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     var name = cmd.Split(new[] { ' ' }, 2)[1];
     repo.Add(new GameObject { Name = name, Location = player });
     console.WriteLine("You create a {0}.", name);
     return true;
 }
        public void Add(BusinessObjects.FeatureSelection entity)
        {
            using (_FeatureSelectionRepository = new GenericRepository<DAL.DataEntities.FeatureSelection>())
            {
                //Add the FeatureSelection
                _FeatureSelectionRepository.Add((DAL.DataEntities.FeatureSelection)entity.InnerEntity);
                _FeatureSelectionRepository.SaveChanges();

                //Add AttributeValues
                using (_AttributeValuesRepository = new GenericRepository<DAL.DataEntities.AttributeValue>())
                {
                    for (int i = entity.AttributeValues.Count - 1; i >= 0; i--)
                    {
                        BLL.BusinessObjects.AttributeValue BLLAttributeValue = entity.AttributeValues[i];
                        BLLAttributeValue.FeatureSelectionID = entity.ID;

                        //Add
                        if (BLLAttributeValue.ToBeDeleted == false && BLLAttributeValue.ID == 0)
                        {
                            _AttributeValuesRepository.Add((DAL.DataEntities.AttributeValue)BLLAttributeValue.InnerEntity);
                        }
                    }
                    _AttributeValuesRepository.SaveChanges();
                }
            }
        }
 public void Add(BusinessObjects.Constraint entity)
 {
     using (_ConstraintRepository = new GenericRepository<DAL.DataEntities.Constraint>())
     {
         _ConstraintRepository.Add((DAL.DataEntities.Constraint)entity.InnerEntity);
         _ConstraintRepository.SaveChanges();
     }
 }
        public void Get_With_String_Selector_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User" };
            repository.Add(contact);

            var result = repository.Get(contact.ContactId, c => c.Name);
            result.ShouldEqual("Test User");
        }
 public void Add(BLL.BusinessObjects.UITemplate entity)
 {
     using (_UITemplateRepository = new GenericRepository<DAL.DataEntities.UITemplate>())
     {
         _UITemplateRepository.Add((DAL.DataEntities.UITemplate)entity.InnerEntity);
         _UITemplateRepository.SaveChanges();
     }
 }
        private void RegistrationEvent(IActivityRegister activityRegister, IRepository repository, ActivityTypes activityType)
        {
            if (repository == null)
                throw new ArgumentNullException(nameof(repository));

            var activity = ActivityCreate(activityRegister.ObjectInfo, activityType);
            repository.Add(activity);
        }
Example #14
0
 public void Add(BusinessObjects.Model entity)
 {
     using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
     {
         _ModelRepository.Add((DAL.DataEntities.Model)entity.InnerEntity);
         _ModelRepository.SaveChanges();
     }
 }
 public void Add(BusinessObjects.CustomRule entity)
 {
     using (_CustomRuleRepository = new GenericRepository<DAL.DataEntities.CustomRule>())
     {
         _CustomRuleRepository.Add((DAL.DataEntities.CustomRule)entity.InnerEntity);
         _CustomRuleRepository.SaveChanges();
     }
 }
Example #16
0
 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     var name = cmd.Split(new[] { ' ' }, 2);
     var room = new Room() { Name = name[1].Trim() };
     repo.Add(room);
     console.WriteLine("Room created");
     return true;
 }
 public void Add(BusinessObjects.Relation entity)
 {
     using (_RelationRepository = new GenericRepository<DAL.DataEntities.Relation>())
     {
         _RelationRepository.Add((DAL.DataEntities.Relation)entity.InnerEntity);
         _RelationRepository.SaveChanges();
     }
 }
        public void Update_Should_Save_Modified_Business_Name(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User" };
            repository.Add(contact);

            var contact2 = new Contact { Name = "Test User 2" };
            repository.Add(contact2);

            contact.Name = "Test User - Updated";
            repository.Update(contact);

            var updated = repository.Get(contact.ContactId);
            var notUpdated = repository.Get(contact2.ContactId);

            updated.Name.ShouldEqual("Test User - Updated");
            notUpdated.Name.ShouldEqual("Test User 2");
        }
 public void Add(BusinessObjects.Feature entity)
 {
     using (_FeatureRepository = new GenericRepository<DAL.DataEntities.Feature>())
     {
         //Add the Feature
         _FeatureRepository.Add((DAL.DataEntities.Feature)entity.InnerEntity);
         _FeatureRepository.SaveChanges();
     }
 }
        public void Get_With_Anonymous_Class_Selector_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User", ContactTypeId = 2 };
            repository.Add(contact);

            var result = repository.Get(contact.ContactId, c => new { c.ContactTypeId, c.Name });
            result.ContactTypeId.ShouldEqual(2);
            result.Name.ShouldEqual("Test User");
        }
 public void Add(BusinessObjects.Attribute entity)
 {
     using (_AttributeRepository = new GenericRepository<DAL.DataEntities.Attribute>())
     {
         //Add the Attribute
         _AttributeRepository.Add((DAL.DataEntities.Attribute)entity.InnerEntity);
         _AttributeRepository.SaveChanges();
     }
 }
        public void Get_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User", ContactTypeId = 1 };
            repository.Add(contact);

            var result = repository.Get(contact.ContactId);
            result.Name.ShouldEqual(contact.Name);
            result.ContactTypeId.ShouldEqual(contact.ContactTypeId);
        }
        public void Average_With_Specification_Should_Return_Average(IRepository<Contact, string> repository)
        {
            for (var i = 1; i <= 3; i++)
            {
                var contact = new Contact { Name = "Test User " + i, ContactTypeId =i};
                repository.Add(contact);
            }

            repository.Average(new Specification<Contact>(x => x.ContactTypeId > 1), x => x.ContactTypeId).ShouldEqual(2.5);
        }
        public void Average_Decimal_With_Predicate_Should_Return_Average(IRepository<Contact, string> repository)
        {
            for (var i = 1; i <= 3; i++)
            {
                var contact = new Contact { Name = "Test User " + i, ContactTypeId = i, SumDecimal = 0.5m + i };
                repository.Add(contact);
            }

            repository.Average(x => x.ContactTypeId > 1, x => x.SumDecimal).ShouldEqual(3m);
        }
        public void Average_All_Should_Return_Average(IRepository<Contact, string> repository)
        {
            for (var i = 1; i <= 3; i++)
            {
                var contact = new Contact { Name = "Test User " + i, ContactTypeId =i};
                repository.Add(contact);
            }

            repository.Average(x => x.ContactTypeId).ShouldEqual(2.0);
        }
        public void Delete_By_Params_Should_Remove_Multiple_Items(IRepository<Contact, string> repository)
        {
            var contact1 = new Contact {Name = "Contact 1", ContactTypeId = 1};
            var contact2 = new Contact {Name = "Contact 2", ContactTypeId = 1};
            var contact3 = new Contact {Name = "Contact 3", ContactTypeId = 3};

            repository.Add(contact1);
            repository.Add(contact2);
            repository.Add(contact3);

            var items = repository.GetAll().ToList();
            items.Count().ShouldEqual(3);

            repository.Delete(contact1.ContactId, contact2.ContactId);

            items = repository.GetAll().ToList();
            items.Count().ShouldEqual(1);
            items.First().Name.ShouldEqual("Contact 3");
        }
Example #27
0
 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     var name = cmd.Split(new[] { ' ' }, 2)[1];
     var room = new Room()
     {
         Name = name
     };
     repo.Add(room);
     return true;
 }
Example #28
0
		protected virtual ObservableChangeTracker GetChangeTracker(IRepository repository)
		{
			var retVal = new ObservableChangeTracker
			{
                RemoveAction = x => repository.Remove(x),
                AddAction = x => repository.Add(x)
			};

			return retVal;
		}
Example #29
0
        public MatchModule(IRepository<Match> matchRepository, IRepository<Country> countryRepository)
            : base("/matches")
        {
            Get["/"] = parameters =>
                           {
                               var matches = matchRepository.FindAll();

                               var resource = matches.ToArray().Select(
                                   m => new MatchResource
                                            {
                                                Id = m.Id,
                                                Date = m.Date,
                                                Team1CountryId = m.Team1.Country.Id,
                                                Team2CountryId = m.Team2.Country.Id
                                            });

                               return Response.AsJson(resource);
                           };

            Post["/"] = parameters =>
                {
                    var resource = this.Bind<MatchResource>();

                    var country1 = countryRepository.GetById(resource.Team1CountryId);
                    if (country1 == null)
                        return HttpStatusCode.BadRequest;

                    var country2 = countryRepository.GetById(resource.Team2CountryId);
                    if (country2 == null)
                        return HttpStatusCode.BadRequest;

                    var match = Match.Create(
                        resource.Date,
                        country1,
                        country2);

                    matchRepository.Add(match);

                    return Response.AsRedirect("/matches/" + match.Id);
                };

            Get["/{id}"] = parameters =>
                {
                    var match = matchRepository.GetById((int)parameters.Id);
                    if (match == null)
                        return HttpStatusCode.NotFound;

                    return Response.AsJson(new
                        {
                            Date = match.Date,
                            Team1 = match.Team1,
                            Team2 = match.Team2
                        });
                };
        }
        public void FindAll_Should_Return_All_Items_Which_Satisfy_Composite_Specification(IRepository<Contact, string> repository)
        {
            for (int i = 1; i <= 3; i++)
            {
                var contact = new Contact { Name = "Test User " + i };
                repository.Add(contact);
            }

            var result = repository.FindAll(new Specification<Contact>(p => p.Name == "Test User 1").OrElse(new Specification<Contact>(p => p.Name == "Test User 2")));
            result.Count().ShouldEqual(2);
        }