public BeeYardHiveComponent(Texture2D blankTexture, BeeHive beeHive, BeeYardHiveInfo hiveInfo, SuperRepository superRepository)
 {
     this.mBlankTexture = blankTexture;
     this.mBeeHive = beeHive;
     this.mHiveInfo = hiveInfo;
     this.mSuperRepository = superRepository;
 }
Example #2
0
        public void WhenInsertCalled_ThenAddsSuperPerson()
        {
            // Arrange
            var superPerson = new SuperPerson()
            {
                Id = 1, Allegiance = "A"
            };

            // Note: Moq example marking a call as verifiable, then verifying all at the end

            var mockEntitySet = new Mock <IEntitySet <SuperPerson> >();

            mockEntitySet.Setup(x => x.Add(superPerson)).Verifiable();

            var mockContext = new Mock <ISuperDatabaseContext>();

            mockContext.Setup(x => x.SuperPeople).Returns(mockEntitySet.Object);

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            target.Insert(superPerson);

            // Assert
            mockEntitySet.VerifyAll();
        }
Example #3
0
        public void WhenGetCalled_ThenReturnsSuperPerson()
        {
            // Arrange
            var superPerson = new SuperPerson()
            {
                Id   = 1,
                Name = "Name1"
            };

            // Note: Moq example of an mocking a method that takes an argument and returns a value
            // Note: Castle-proxy is under each mock => requires interface or virtual

            var mockContext = new Mock <ISuperDatabaseContext>();

            mockContext.Setup(x => x.SuperPeople.Find(1)).Returns(superPerson);

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            var actual = target.Get(1);

            // Assert
            Assert.AreSame(superPerson, actual);

            mockContext.Verify(x => x.SuperPeople.Find(1), Times.Once());
        }
Example #4
0
        public void WhenDeleteCalled_ThenRemovesSuperPerson()
        {
            // Arrange
            var superPerson = new SuperPerson()
            {
                Id = 1, Allegiance = "A"
            };

            var mockEntitySet = new Mock <IEntitySet <SuperPerson> >();

            mockEntitySet.Setup(x => x.Remove(superPerson)).Verifiable();

            var mockContext = new Mock <ISuperDatabaseContext>();

            mockContext.Setup(x => x.SuperPeople).Returns(mockEntitySet.Object);

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            target.Delete(superPerson);

            // Assert
            mockEntitySet.VerifyAll();
        }
Example #5
0
        public void WhenGetTeamCalled_ThenReturnsFilteredCollection()
        {
            // Arrange
            var superPeople = new List <SuperPerson>()
            {
                new SuperPerson()
                {
                    Id = 1, Allegiance = "A"
                },
                new SuperPerson()
                {
                    Id = 2, Allegiance = "B"
                },
                new SuperPerson()
                {
                    Id = 3, Allegiance = "A"
                },
            };

            var filteredSuperPeople = new List <SuperPerson>()
            {
                superPeople[0],
                superPeople[2]
            };

            var mockEntitySet = new Mock <IEntitySet <SuperPerson> >();

            var mockEnumerable = mockEntitySet.As <IEnumerable <SuperPerson> >();

            mockEnumerable.Setup(x => x.GetEnumerator()).Returns(superPeople.GetEnumerator());

            // Note: Moq example of an mocking a method specific to an interface (complexity => Reflector)

            var mockQueryable = mockEntitySet.As <IQueryable <SuperPerson> >();

            mockQueryable.Setup(x => x.Provider).Returns(superPeople.AsQueryable().Provider);
            mockQueryable.Setup(x => x.Expression).Returns(superPeople.AsQueryable().Expression);

            var mockContext = new Mock <ISuperDatabaseContext>();

            mockContext.Setup(x => x.SuperPeople).Returns(mockEntitySet.Object);

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            var actual = target.GetTeam("A");

            // Assert
            var actualList = actual.ToList();

            Assert.AreEqual(2, actualList.Count);

            Assert.AreSame(superPeople[0], actualList[0]);
            Assert.AreSame(superPeople[2], actualList[1]);
        }
Example #6
0
        public void WhenConstructedWithNull_ThenThrows()
        {
            // Arrange
            ISuperDatabaseContext context = null;

            // Act
            SuperRepository actual = new SuperRepository(context);

            // Assert
        }
Example #7
0
        private void InitializeArena()
        {
            var repository = new SuperRepository(new SuperDatabaseContext());
            var arena      = new ChallengeArena(repository, new SlugFestFightStrategy(new Dice(100)));

            arena.FightLog = this;
            arena.Load(TeamNames.SuperFriends, TeamNames.LegionOfDoom);

            this.Arena = arena;

            this.Arena.PropertyChanged += this.Arena_PropertyChanged;
        }
Example #8
0
        public void WhenDeleteCalledWithNull_ThenThrows()
        {
            // Arrange
            var mockContext = new Mock <ISuperDatabaseContext>();

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            target.Delete(null);

            // Assert
        }
Example #9
0
        public void WhenGetCalledWithIdLessThanOne_ThenThrows()
        {
            // Arrange
            var mockContext = new Mock <ISuperDatabaseContext>();

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            target.Get(0);

            // Assert
        }
Example #10
0
        public void WhenGetTeamCalledWithEmptyString_ThenThrows()
        {
            // Arrange
            var mockContext = new Mock <ISuperDatabaseContext>();

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            target.GetTeam(string.Empty);

            // Assert
        }
Example #11
0
        public override void LoadContent()
        {
            base.LoadContent();

            this.mBlankTexture = this.ContentManager.Load<Texture2D>("Sprites/Blank");
            this.mMetaInfoFont = this.ContentManager.Load<SpriteFont>("Fonts/DefaultTiny");
            this.mSuperRepository = new SuperRepository(this.ContentManager);

            this.mButtonBeeWorld.Click += this.ButtonBeeWorld_Click;
            this.mButtonBeeWorld.Font = this.ContentManager.Load<SpriteFont>("Fonts/DefaultSmall");
            this.mButtonBeeWorld.Text = "World";
            this.mButtonBeeWorld.TextColor = Color.White;
            this.mButtonBeeWorld.BackgroundRenderer = new SolidBackgroundRenderer(this.mBlankTexture, Color.Blue);
            this.mButtonBeeWorld.Size = new Vector2(75, 30);
            this.mButtonBeeWorld.Position = new Vector2(10, this.ScreenSize.Y - this.mButtonBeeWorld.Size.Y - 10);

            this.mButtonMowGrass.Click += this.ButtonMowGrass_Click;
            this.mButtonMowGrass.Font = this.ContentManager.Load<SpriteFont>("Fonts/DefaultSmall");
            this.mButtonMowGrass.Text = "Mow Grass";
            this.mButtonMowGrass.TextColor = Color.Black;
            this.mButtonMowGrass.BackgroundRenderer = new SolidBackgroundRenderer(this.mBlankTexture, Color.Yellow);
            this.mButtonMowGrass.Size = new Vector2(100, 35);
            this.mButtonMowGrass.Position = new Vector2(this.ScreenSize.X - this.mButtonMowGrass.Size.X - 10, 10);

            this.mPlayer = this.ScreenManager.Player;
            System.Diagnostics.Debug.Assert(this.mPlayer.CurrentBeeHive == null);
            System.Diagnostics.Debug.Assert(this.mPlayer.CurrentBeeYard != null);
            this.mBeeYard = this.mPlayer.CurrentBeeYard;
            this.mBeeYardManager = this.ScreenManager.BeeWorldManager.PlayerManager.BeeYardManagers[this.mBeeYard.Id];

            var lAssetName = string.Concat("GraphicsData/BeeYard/HiveInformation_", this.mBeeYard.Id);
            var lHiveInfos = this.ContentManager.Load<BeeYardHiveInfo[]>(lAssetName);

            this.mHiveComponents = new BeeYardHiveComponent[lHiveInfos.Length];
            var lGreenBackgroundRenderer = new SolidBackgroundRenderer(this.mBlankTexture, Color.Green);

            for (int lIndex = 0; lIndex < this.mHiveComponents.Length; lIndex++)
            {
                var lHiveComponent = new BeeYardHiveComponent(
                    this.mBlankTexture,
                    this.mBeeYard.BeeHives[lIndex],
                    lHiveInfos[lIndex],
                    this.mSuperRepository);
                lHiveComponent.TravelToHive += this.HiveComponent_TravelToHive;

                this.mHiveComponents[lIndex] = lHiveComponent;
            }

            this.mHudComponent = new BeeYardHubComponent(this.ScreenManager.BeeWorldManager, this.ScreenSize);
            this.mHudComponent.LoadContent(this.ContentManager);
        }
Example #12
0
        public void WhenGetAllCalled_ThenReturnsCollection()
        {
            // Arrange
            var superPeople = new List <SuperPerson>()
            {
                new SuperPerson()
                {
                    Id = 1
                },
                new SuperPerson()
                {
                    Id = 2
                },
                new SuperPerson()
                {
                    Id = 3
                },
            };

            var mockEntitySet = new Mock <IEntitySet <SuperPerson> >();

            // Note: Moq example of an mocking a method specific to an interface

            var mockEnumerable = mockEntitySet.As <IEnumerable <SuperPerson> >();

            mockEnumerable.Setup(x => x.GetEnumerator()).Returns(superPeople.GetEnumerator());

            // Note: Moq example of an mocking the return of a get accessor
            var mockContext = new Mock <ISuperDatabaseContext>();

            mockContext.Setup(x => x.SuperPeople).Returns(mockEntitySet.Object);

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            var actual = target.GetAll();

            // Assert
            var actualList = actual.ToList();

            Assert.AreEqual(superPeople.Count, actualList.Count);

            for (int i = 0; i < superPeople.Count; i++)
            {
                Assert.AreSame(superPeople[i], actualList[i]);
            }
        }
Example #13
0
        public void WhenSaveChangesCalled_ThenSavesChanges()
        {
            // Arrange
            var mockContext = new Mock <ISuperDatabaseContext>();

            mockContext.Setup(x => x.SaveChanges()).Verifiable();

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            target.SaveChanges();

            // Assert
            mockContext.VerifyAll();
        }
Example #14
0
        public void WhenConstructed_ThenInstantiated()
        {
            // Note: Moq example of an empty mocked instance.
            // Note: Default behavior is non-strict (no-ops and default values)

            // Note: Naming of mocked variables is important

            // Arrange
            var mockContext = new Mock <ISuperDatabaseContext>();

            ISuperDatabaseContext context = mockContext.Object;

            // Act
            SuperRepository actual = new SuperRepository(context);

            // Assert
            Assert.IsNotNull(actual);
        }
Example #15
0
        public void WhenUpdateCalled_ThenUpdatesSuperPerson()
        {
            // Arrange
            var superPerson = new SuperPerson()
            {
                Id = 1, Allegiance = "A"
            };

            var mockContext = new Mock <ISuperDatabaseContext>();

            mockContext.Setup(x => x.SetEntityStateModified(superPerson)).Verifiable();

            ISuperDatabaseContext context = mockContext.Object;
            SuperRepository       target  = new SuperRepository(context);

            // Act
            target.Update(superPerson);

            // Assert
            mockContext.VerifyAll();
        }
Example #16
0
 public VehicleTypesController()
 {
     _repo = new SuperRepository();
 }
        public override void LoadContent()
        {
            base.LoadContent();

            this.mPlayerManager = this.ScreenManager.BeeWorldManager.PlayerManager;
            this.mPlayer = this.mPlayerManager.Player;

            this.mSuperPaintRepository = new SuperPaintRepository(this.ContentManager);
            this.mSuperRepository = new SuperRepository(this.ContentManager);

            this.mBlankTexture = this.ContentManager.Load<Texture2D>("Sprites/Blank");

            this.mConfirmationDialogComponent = new ConfirmationDialogComponent(this.ScreenSize);
            this.mConfirmationDialogComponent.LoadContent(this.ContentManager);
            this.mConfirmationDialogComponent.CancelText = "No";
            this.mConfirmationDialogComponent.ConfirmText = "Yes";
            this.mConfirmationDialogComponent.Confirm += this.ConfirmationDialogComponent_Confirm;
            this.mConfirmationDialogComponent.Cancel += this.ConfirmationDialogComponent_Cancel;

            this.mButtonMenuComponent = new ButtonMenuComponent(this.ScreenSize);
            this.mButtonMenuComponent.LoadContent(this.ContentManager);
            this.mButtonMenuComponent.MenuButtons.Add(this.mMenuButtonBuy);
            this.mButtonMenuComponent.MenuButtons.Add(this.mMenuButtonBack);
            //
            // mHudComponent
            //
            this.mHudComponent = new ShopScreenHudComponent(this.ScreenManager.BeeWorldManager, this.ScreenSize);
            this.mHudComponent.LoadContent(this.ContentManager);
            //
            // mMiddleSuperItemComponent
            //
            this.mMiddleSuperItemComponent.LoadContent(this.ContentManager);
            this.mMiddleSuperItemComponent.IconTexture = this.mBlankTexture;
            this.mMiddleSuperItemComponent.Size = this.mSuperItemSize;
            this.mMiddleSuperItemComponent.Position = new Vector2(
                ((this.ScreenSize.X - this.mSuperItemSize.X - this.mSuperPaintItemSize.X)/2f),
                ((this.ScreenSize.Y - this.mSuperItemSize.Y - this.mHudComponent.Size.Y)/2f));
            this.mMiddleSuperItemComponent.NameText = "Middle";
            this.mMiddleSuperItemComponent.DescriptionText = "This is the middle item.";
            this.mMiddleSuperItemComponent.Price = 2;
            this.mMiddleSuperItemComponent.Click += this.SelectItemComponent;
            this.PopulateItemComponent(
                this.mMiddleSuperItemComponent,
                this.mSuperRepository.GetMetaObject(1));

            this.mTopSuperItemComponent.LoadContent(this.ContentManager);
            this.mTopSuperItemComponent.IconTexture = this.mBlankTexture;
            this.mTopSuperItemComponent.Size = this.mSuperItemSize;
            this.mTopSuperItemComponent.Position = new Vector2(
                this.mMiddleSuperItemComponent.Position.X,
                this.mMiddleSuperItemComponent.Position.Y - sItemPadding - this.mSuperItemSize.Y);
            this.mTopSuperItemComponent.NameText = "Top";
            this.mTopSuperItemComponent.DescriptionText = "This is the top item.";
            this.mTopSuperItemComponent.Price = 1;
            this.mTopSuperItemComponent.Click += this.SelectItemComponent;
            this.PopulateItemComponent(
                this.mTopSuperItemComponent,
                this.mSuperRepository.GetMetaObject(0));

            this.mBottomSuperItemComponent.LoadContent(this.ContentManager);
            this.mBottomSuperItemComponent.IconTexture = this.mBlankTexture;
            this.mBottomSuperItemComponent.Size = this.mSuperItemSize;
            this.mBottomSuperItemComponent.Position =
            this.mBottomSuperItemComponent.Position = new Vector2(
                this.mMiddleSuperItemComponent.Position.X,
                this.mMiddleSuperItemComponent.Position.Y + this.mSuperItemSize.Y + sItemPadding);
            this.mBottomSuperItemComponent.NameText = "Right";
            this.mBottomSuperItemComponent.DescriptionText = "This is the bottom item.";
            this.mBottomSuperItemComponent.Price = 3;
            this.mBottomSuperItemComponent.Click += this.SelectItemComponent;
            this.PopulateItemComponent(
                this.mBottomSuperItemComponent,
                this.mSuperRepository.GetMetaObject(2));

            this.mTopSuperPaintItemComponent.LoadContent(this.ContentManager);
            this.mTopSuperPaintItemComponent.IconTexture = this.mBlankTexture;
            this.mTopSuperPaintItemComponent.Size = this.mSuperPaintItemSize;
            this.mTopSuperPaintItemComponent.Position = new Vector2(
                this.mTopSuperItemComponent.Position.X + this.mSuperItemSize.X + sItemPadding,
                this.mTopSuperItemComponent.Position.Y);
            this.mTopSuperPaintItemComponent.NameText = "Top";
            this.mTopSuperPaintItemComponent.DescriptionText = "This is the top item.";
            this.mTopSuperPaintItemComponent.Price = 4;
            this.mTopSuperPaintItemComponent.Click += this.SelectItemComponent;

            this.mMiddleTopSuperPaintItemComponent.LoadContent(this.ContentManager);
            this.mMiddleTopSuperPaintItemComponent.IconTexture = this.mBlankTexture;
            this.mMiddleTopSuperPaintItemComponent.Size = this.mSuperPaintItemSize;
            this.mMiddleTopSuperPaintItemComponent.Position = new Vector2(
                this.mTopSuperPaintItemComponent.Position.X,
                this.mTopSuperPaintItemComponent.Position.Y + this.mSuperPaintItemSize.Y + sItemPadding);
            this.mMiddleTopSuperPaintItemComponent.NameText = "Middle Top";
            this.mMiddleTopSuperPaintItemComponent.DescriptionText = "This is the middle-top item.";
            this.mMiddleTopSuperPaintItemComponent.Price = 5;
            this.mMiddleTopSuperPaintItemComponent.Click += this.SelectItemComponent;

            this.mMiddleBottomSuperPaintItemComponent.LoadContent(this.ContentManager);
            this.mMiddleBottomSuperPaintItemComponent.IconTexture = this.mBlankTexture;
            this.mMiddleBottomSuperPaintItemComponent.Size = this.mSuperPaintItemSize;
            this.mMiddleBottomSuperPaintItemComponent.Position = new Vector2(
                this.mTopSuperPaintItemComponent.Position.X,
                this.mMiddleTopSuperPaintItemComponent.Position.Y + this.mSuperPaintItemSize.Y + sItemPadding);
            this.mMiddleBottomSuperPaintItemComponent.NameText = "Middle Bottom";
            this.mMiddleBottomSuperPaintItemComponent.DescriptionText = "This is the middle-bottom item.";
            this.mMiddleBottomSuperPaintItemComponent.Price = 6;
            this.mMiddleBottomSuperPaintItemComponent.Click += this.SelectItemComponent;

            this.mBottomSuperPaintItemComponent.LoadContent(this.ContentManager);
            this.mBottomSuperPaintItemComponent.IconTexture = this.mBlankTexture;
            this.mBottomSuperPaintItemComponent.Size = this.mSuperPaintItemSize;
            this.mBottomSuperPaintItemComponent.Position = new Vector2(
                this.mTopSuperPaintItemComponent.Position.X,
                this.mMiddleBottomSuperPaintItemComponent.Position.Y + this.mSuperPaintItemSize.Y + sItemPadding);
            this.mBottomSuperPaintItemComponent.NameText = "Bottom";
            this.mBottomSuperPaintItemComponent.DescriptionText = "This is the bottom item.";
            this.mBottomSuperPaintItemComponent.Price = 7;
            this.mBottomSuperPaintItemComponent.Click += this.SelectItemComponent;
        }
Example #18
0
 public ClassUnitsController()
 {
     _repo = new SuperRepository();
 }
Example #19
0
 public OwnersController()
 {
     _repo = new SuperRepository();
 }
Example #20
0
 public PeopleController()
 {
     _repo = new SuperRepository();
 }
Example #21
0
        public override void LoadContent()
        {
            base.LoadContent();

            var lPlayerManager = this.ScreenManager.BeeWorldManager.PlayerManager;
            this.mPlayer = lPlayerManager.Player;
            System.Diagnostics.Debug.Assert(this.mPlayer.Location == PlayerLocation.BeeHive);
            this.mBeeHive = this.mPlayer.CurrentBeeHive;
            var lBeeYardManager = lPlayerManager.BeeYardManagers[this.mPlayer.CurrentBeeYard.Id];
            this.mBeeHiveManager = lBeeYardManager.BeeHiveManagers[this.mBeeHive.Id];

            this.mBlankTexture = this.ContentManager.Load<Texture2D>("Sprites/Blank");
            this.mMetaInfoFont = this.ContentManager.Load<SpriteFont>("Fonts/DefaultTiny");
            this.mSuperRepository = new SuperRepository(this.ContentManager);

            this.mButtonMenuComponent = new ButtonMenuComponent(this.ScreenSize);
            this.mButtonMenuComponent.LoadContent(this.ContentManager);
            this.mButtonMenuComponent.MenuButtons.Add(this.mMenuButtonSupers);
            this.mButtonMenuComponent.MenuButtons.Add(this.mMenuButtonQueen);
            this.mButtonMenuComponent.MenuButtons.Add(this.mMenuButtonUseSmoker);
            this.mButtonMenuComponent.MenuButtons.Add(this.mMenuButtonToYard);
            this.mButtonMenuComponent.MenuButtons.Add(this.mMenuButtonToWorld);
            this.mButtonMenuComponent.MenuButtons.Add(this.mMenuButtonSelectionCommit);
            this.mButtonMenuComponent.MenuButtons.Add(this.mMenuButtonSelectionCancel);

            this.mHudComponent = new BeeHiveHudComponent(this.ScreenManager.BeeWorldManager, this.ScreenSize);
            this.mHudComponent.LoadContent(this.ContentManager);

            this.mVerticalScrollUpBounds = new Rectangle(
                (int)((this.ScreenSize.X - this.mSuperWidth) / 2f), 0,
                this.mSuperWidth, this.mScrollBoundsHeight);
            this.mVerticalScrollDownBounds = new Rectangle(
                this.mVerticalScrollUpBounds.X,
                (int)this.mHudComponent.Position.Y - this.mVerticalScrollUpBounds.Height,
                this.mVerticalScrollUpBounds.Width,
                this.mVerticalScrollUpBounds.Height + (int)this.mHudComponent.Size.Y);

            this.mInventorySelectorComponent = new InventoryItemSelectorComponent(this.ScreenSize);
            this.mInventorySelectorComponent.LoadContent(this.ContentManager);

            this.mSuperTexture = new Texture2D(this.ScreenManager.Game.GraphicsDevice, 128, 128);
            this.mSuperTexture.SetData(Enumerable.Repeat(Color.Pink, 128 * 128).ToArray());

            this.mComponents.Add(this.mInventorySelectorComponent);
            this.mComponents.Add(this.mButtonMenuComponent);
            this.mComponents.Add(this.mHudComponent);
        }