Пример #1
0
 public void InitBrand(SeralizedClassServer.CollectionList collectionBrand, CollectionController mCollectionController)
 {
     collectionController = mCollectionController;
     brand          = collectionBrand;
     brandName.text = collectionBrand.collection_name;
     StartCoroutine("LoadImage", "http://www.jongwings.com/chivita/" + collectionBrand.recipes_image);
 }
        public async Task Get_ShouldReturnList()
        {
            // Arrange
            var controller = new CollectionController();

            // Act
            var actionResult = await controller.Get();

            var contentResult = actionResult as OkNegotiatedContentResult <List <Aggregate> >;
            var actual        = contentResult?.Content;

            // Assert
            Assert.IsNotNull(actionResult);
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(actual);
            Assert.AreEqual(30, actual.Count());

            // make sure all 30 records contain valid objects
            Assert.IsTrue(actual.All(m => m.Album != null));
            Assert.IsTrue(actual.All(m => m.Post != null));
            Assert.IsTrue(actual.All(m => m.User != null));

            // make sure randomness has been applied
            Assert.AreNotEqual(30, actual.Count(m => m.Album.Id == actual.First().Album.Id));
            Assert.AreNotEqual(30, actual.Count(m => m.Post.Id == actual.First().Post.Id));
            Assert.AreNotEqual(30, actual.Count(m => m.User.Id == actual.First().User.Id));
        }
 public new virtual void SetUp()
 {
     base.SetUp();
     CollectionViewModelGetter.Get(InvalidCollectionId).Returns(x =>
                                                                { throw new CollectionIdNotValidException(); });
     _result = (RedirectToRouteResult)CollectionController.Index(CollectionId);
 }
Пример #4
0
 void OnEnable()
 {
     diveManager          = FindObjectOfType <DiveManager>();
     collectionController = FindObjectOfType <CollectionController>();
     playerController     = FindObjectOfType <PlayerController4>();
     UpdateUI();
 }
Пример #5
0
    public CollectionData(CollectionController data)
    {
        collectionName    = data.collectionName.text;
        gamesInCollection = data.copy.gamesCount;

        gamesTitle    = new string[gamesInCollection];
        gamesPlatform = new string[gamesInCollection];
        gamesData     = new string[gamesInCollection];
        gamesGener1   = new string[gamesInCollection];
        gamesGener2   = new string[gamesInCollection];
        gamesRate     = new float [gamesInCollection];
        gamesUrl      = new string[gamesInCollection];
        gamesImageUrl = new string[gamesInCollection];

        var games = data.copy.gamesInCollection;

        for (int i = 0; i < gamesInCollection; i++)
        {
            gamesTitle[i]    = games[i].title;
            gamesPlatform[i] = games[i].platform;
            gamesData[i]     = games[i].gameDate;
            gamesGener1[i]   = games[i].genre1;
            gamesGener2[i]   = games[i].genre2;
            gamesRate[i]     = games[i].tag;
            gamesUrl[i]      = games[i].gameUrl;
            gamesImageUrl[i] = games[i].imageUrl;
        }
    }
 public static CollectionController Instance()
 {
     if (!collectionController)
     {
         collectionController = FindObjectOfType <CollectionController>();
     }
     return(collectionController);
 }
        public void User_Can_Not_Update_Collections_With_Duplicate_Names()
        {
            // Spoof an authenticated user by generating a ClaimsPrincipal
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
                new Claim(ClaimTypes.NameIdentifier, "FIREBASE_ID_1"),
            }, "TestAuthentication"));

            // Instantiate a real repos
            var collectionRepo = new CollectionRepository(_context);
            var userRepo       = new UserRepository(_context);
            var projColRepo    = new ProjectCollectionRepository(_context);

            // Instantiate a real CollectionController, passing in CollectionRepo
            var controller = new CollectionController(userRepo, collectionRepo, projColRepo);

            controller.ControllerContext             = new ControllerContext(); // Required to create the controller
            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = user
            };                                                                                 // Pretend the user is making a request to the controller

            // Create a collection with a duplicate name
            // create a new collectionFormViewModel
            var collectionForm = new CollectionFormViewModel()
            {
                Collection = new Collection()
                {
                    Id               = 2,
                    UserId           = 1,
                    CategorizationId = 1,
                    Name             = "Monsters",
                    Description      = "HA-HA! The titles match >:)",
                    Pinned           = false,
                    CreationDate     = DateTime.Now - TimeSpan.FromDays(15)
                },

                ProjectCollections = new List <ProjectCollection>()
                {
                    new ProjectCollection()
                    {
                        ProjectId    = 1,
                        CollectionId = 0 // I won't know this until it's made
                    },
                    new ProjectCollection()
                    {
                        ProjectId    = 2,
                        CollectionId = 0 // I won't know this until it's made
                    }
                }
            };

            // Attempt to Update collection
            var response = controller.Put(collectionForm.Collection.Id, collectionForm);

            // Should return created result
            Assert.IsType <NotFoundResult>(response);
        }
Пример #8
0
        private void Awake()
        {
            startThoughtsProvider        = viewContext.StartThoughtsProvider;
            collectionThoughtsProvider   = viewContext.CollectionThoughtsProvider;
            notificationThoughtsProvider = viewContext.NotificationThoughtsProvider;

            viewStateController = viewContext.ViewStateController;

            modelController      = modelContext.ModelController;
            collectionController = modelContext.CollectionController;
        }
Пример #9
0
 // unity functions
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this.gameObject);
     }
 }
Пример #10
0
    public static void SaveCollection(CollectionController data)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/" + data.collectionName.text + "_collection.gg";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        CollectionData collectionData = new CollectionData(data);

        formatter.Serialize(stream, collectionData);
        stream.Close();
    }
        public void Init()
        {
            const string connectionString = "mongodb://*****:*****@ds027308.mongolab.com:27308/disccatalog_test";
            var          mongoClient      = new MongoClient(connectionString);
            var          mongoServer      = mongoClient.GetServer();

            _database = mongoServer.GetDatabase("disccatalog_test");

            PrepareDatabase();

            _collectionController = new CollectionController(_database);
        }
Пример #12
0
 public void InitBrand1(SeralizedClassServer.OfflineCollectionDetails collectionBrand, CollectionController mCollectionController)
 {
     collectionController = mCollectionController;
     brand1         = collectionBrand;
     brandName.text = collectionBrand.CollectionName;
     if (collectionBrand.CollectionName == "Cocktails")
     {
         brandIcon.sprite = AppManager.Instance.RecipeOfflineImages[4];
     }
     else if (collectionBrand.CollectionName == "Mixtures")
     {
         brandIcon.sprite = AppManager.Instance.RecipeOfflineImages[0];
     }
 }
        public CollectionControllerTest()
        {
            var connection = "TESTDB";
            var options    = new DbContextOptionsBuilder <SiCContext>()
                             .UseInMemoryDatabase(connection)
                             .Options;

            context = new SiCContext(options);

            List <Collection> collections = new List <Collection>();

            foreach (Collection c in context.Collection)
            {
                collections.Add(c);
            }

            if (collections.Count == 0)
            {
                Collection mock1 = new Collection();
                mock1.collectionName     = "Test_Collection";
                mock1.aestheticParameter = "Mock_Parameter";
                mock1.CollectionProducts = new List <CollectionProduct>();

                Collection mock2 = new Collection();
                mock2.collectionName     = "Second_Test_Collection";
                mock2.aestheticParameter = "Second_Mock_Parameter";
                mock2.CollectionProducts = new List <CollectionProduct>();

                Category mock3 = new Category();
                mock3.description = "This is a mock Category";
                mock3.name        = "Test_Category";
                mock3.parent      = null;

                Product mock4 = new Product();
                mock4.CatalogProducts    = new List <CatalogProduct>();
                mock4.CollectionProducts = new List <CollectionProduct>();
                mock4.ProductMaterials   = new List <ProductMaterial>();
                mock4.description        = "This is a mock Product";
                mock4.dimensions         = new List <Dimension>();
                mock4.name = "Test_Product";

                context.Collection.Add(mock1);
                context.Collection.Add(mock2);
                context.Category.Add(mock3);
                context.Product.Add(mock4);
                context.SaveChanges();
            }
            controller = new CollectionController(context);
        }
Пример #14
0
        /// <summary>
        /// Initialize a new instance of the <see cref="T:Kuzzle.Kuzzle"/> class.
        /// </summary>
        public Kuzzle(
            AbstractProtocol networkProtocol,
            int refreshedTokenDuration       = 3600000,
            int minTokenDuration             = 3600000,
            int maxQueueSize                 = -1,
            int maxRequestDelay              = 1000,
            bool autoRecover                 = false,
            Func <JObject, bool> queueFilter = null
            )
        {
            NetworkProtocol = networkProtocol;
            NetworkProtocol.ResponseEvent += ResponsesListener;
            NetworkProtocol.StateChanged  += StateChangeListener;

            EventHandler = new KuzzleEventHandler(this);

            // Initializes the controllers
            Auth       = new AuthController(this);
            Collection = new CollectionController(this);
            Document   = new DocumentController(this);
            Index      = new IndexController(this);
            Realtime   = new RealtimeController(this);
            Server     = new ServerController(this);
            Bulk       = new BulkController(this);
            Admin      = new AdminController(this);

            Offline = new OfflineManager(networkProtocol, this)
            {
                RefreshedTokenDuration = refreshedTokenDuration,
                MinTokenDuration       = minTokenDuration,
                MaxQueueSize           = maxQueueSize,
                MaxRequestDelay        = maxRequestDelay,
                QueueFilter            = queueFilter,
                AutoRecover            = autoRecover
            };

            // Initializes instance unique properties
            Version = typeof(Kuzzle)
                      .GetTypeInfo()
                      .Assembly
                      .GetName()
                      .Version
                      .ToString();

            InstanceId = Guid.NewGuid().ToString();

            SdkName = $"csharp@{Version}";
        }
Пример #15
0
    private void Awake()
    {
        if (CollectionController.collectionController == null)
        {
            CollectionController.collectionController = this;
        }
        else
        {
            Destroy(this.gameObject);
        }

        DontDestroyOnLoad(this.gameObject);

        completeDeck = new ListWrapper[editorDeck.Length];
        for (int i = 0; i < editorDeck.Length; i++)
        {
            completeDeck[i] = new ListWrapper();
            List <CardController> temp = new List <CardController>();
            foreach (Card c in editorDeck[i].deck)
            {
                CardController j = this.gameObject.AddComponent <CardController>();
                j.SetCard(c, true, false);
                temp.Add(j);
            }
            completeDeck[i].SetDeck(temp);
        }

        selectedDeck = new ListWrapper[editorDeck.Length]; //Deep copy completeDeck to avoid deleting cards in that list
        for (int i = 0; i < completeDeck.Length; i++)
        {
            selectedDeck[i] = new ListWrapper();
            List <CardController> temp = new List <CardController>();
            foreach (CardController c in completeDeck[i].deck)
            {
                temp.Add(c);
            }
            selectedDeck[i].SetDeck(temp);
        }

        ReCountUniqueCards();
        SetDeck(0);
        ResolveSelectedList();
        FinalizeDeck();
        CheckDeckComplete();
        CheckPageButtons();
        RefreshDecks();
    }
        public CollectionControllerTest()
        {
            _mockDiscogsRepository = new();
            _mockLogger            = new();
            _mockMappingService    = new();
            _collectionController  = new(_mockDiscogsRepository.Object, _mockLogger.Object, _mockMappingService.Object);

            if (_mapper == null)
            {
                var mappingConfig = new MapperConfiguration(mc =>
                {
                    mc.AddProfile(new MapperProfile());
                });
                IMapper mapper = mappingConfig.CreateMapper();
                _mapper = mapper;
            }
        }
Пример #17
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int id = 0;

            int.TryParse(tbCollectionId.Text, out id);

            DateTime     captureDateTime = DateTime.Parse(tbDateTime.Text);
            Catalogue    catalogue       = listCatalogues[cbCatalogue.SelectedIndex];
            int          objectId        = int.Parse(tbObjectId.Text);
            string       objectTitle     = tbObjectTitle.Text;
            int          numberFrames    = Convert.ToInt32(tbTotalFrames.Value);
            FileFormat   fileFormat      = listFileFormats[cbFileFormat.SelectedIndex];
            ColorSpace   colorSpace      = listColorSpaces[cbColorSpace.SelectedIndex];
            Camera       camera          = listCameras[cbCamera.SelectedIndex];
            Scope        scope           = listScopes[cbScope.SelectedIndex];
            Site         site            = listSites[cbSite.SelectedIndex];
            List <Optic> optics          = new List <Optic>();

            foreach (var item in clbOptics.CheckedItems)
            {
                int opticId = int.Parse(item.ToString().Split('|')[0]);
                optics.Add(listOptics.Where(x => x.Id == opticId).ToList()[0]);
            }

            Photographer photographer = listPhotographers[cbPhotographer.SelectedIndex];
            Size         resolution   = Utilities.StringToResolution(tbResolutionX.Text + ";" + tbResolutionY.Text);
            string       comments     = tbComments.Text;
            string       fileName     = tbFile.Text;
            string       metadataFile = tbMetadataFile.Text;

            Collection collection = new Collection(id, captureDateTime, catalogue, objectId, objectTitle,
                                                   numberFrames, fileFormat, colorSpace, camera, scope, site, optics, photographer,
                                                   resolution, comments, fileName, metadataFile);

            if (EditingMode == frmManager.EditingModes.Add)
            {
                CollectionController.AddCollection(collection);
            }
            else
            {
                CollectionController.EditCollection(id, collection);
            }

            ClearData();
            PopulateTreeView();
        }
        public void Anonymous_User_Can_Not_Add_Collection()
        {
            // Spoof an authenticated user by generating a ClaimsPrincipal
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
                new Claim(ClaimTypes.NameIdentifier, "FIREBASE_USER666"),
            }, "TestAuthentication"));

            // create a new collectionFormViewModel
            var collectionForm = new CollectionFormViewModel()
            {
                Collection = new Collection()
                {
                    UserId           = 1,
                    CategorizationId = 1,
                    Name             = "New stuff",
                    Description      = "New lame description.",
                    Pinned           = false,
                    CreationDate     = DateTime.Now - TimeSpan.FromDays(10)
                },

                ProjectCollections = new List <ProjectCollection>()
                {
                    new ProjectCollection()
                    {
                        ProjectId    = 1,
                        CollectionId = 0
                    }
                }
            };

            // Spoof UserController
            var controller = new CollectionController(_fakeUserRepo.Object, _fakeCollectionRepo.Object, _fakeProjColRepo.Object);

            controller.ControllerContext             = new ControllerContext(); // Required to create the controller
            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = user
            };                                                                                 // Pretend the user is making a request to the controller

            // Attempt to Get this User's collections
            var response = controller.Add(collectionForm);

            // Returns Ok
            Assert.IsType <NotFoundResult>(response);
            // Verify we never called the repo method
            _fakeCollectionRepo.Verify(r => r.Add(It.IsAny <Collection>()), Times.Never());
        }
    private void GenerateCollectionList(List <Collection> collections)
    {
        GameObject tmpCollectionGo;

        /// Destroy all children
        foreach (Transform child in ParentViewPortGo.transform)
        {
            GameObject.Destroy(child.gameObject);
        }
        foreach (Collection collection  in collections)
        {
            tmpCollectionGo = Instantiate(CollectionPrefab, ParentViewPortGo.transform);
            CollectionController collectionController = tmpCollectionGo.GetComponent <CollectionController>();
            collectionController.LoadingScreen = LoadingScreenGo;
            collectionController.CarpetListGo  = CarpetListGo;
            collectionController.FillContent(RoomCategoryId, StyleCategoryId, collection);
        }
    }
Пример #20
0
        public void Should_be_possible_raising_a_collection_event_on_a_view()
        {
            MockRepository mocks = new MockRepository();

            var fakeView = mocks.DynamicMock <ICollectionView>();

            mocks.ReplayAll();

            var controller = new CollectionController(fakeView);

            var e = new RequestCollectionEvenArgs();

            fakeView.Raise(x => x.OnRequestCollection += null, this, e);

            mocks.VerifyAll();

            Assert.IsTrue(controller.OnRequestCollectionCalled);
        }
Пример #21
0
        public void Should_be_possible_raising_a_collection_event_on_a_view()
        {
            MockRepository mocks = new MockRepository();

            var fakeView = mocks.DynamicMock<ICollectionView>();

            mocks.ReplayAll();

            var controller = new CollectionController(fakeView);

            var e = new RequestCollectionEvenArgs();

            fakeView.Raise(x => x.OnRequestCollection += null, this, e);

            mocks.VerifyAll();

            Assert.IsTrue(controller.OnRequestCollectionCalled);
        }
        public void If_This_Collection_To_Update_Is_Not_Mine_Do_Not_Update()
        {
            // Spoof an authenticated user by generating a ClaimsPrincipal
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
                new Claim(ClaimTypes.NameIdentifier, "FIREBASE_USER2"),
            }, "TestAuthentication"));

            // Make a fake collection to update
            Collection collection = new Collection()
            {
                Id               = 1,
                UserId           = 1,
                CategorizationId = 1,
                Name             = "New stuff",
                Description      = "New lame description.",
                Pinned           = false,
                CreationDate     = DateTime.Now - TimeSpan.FromDays(10)
            };

            // Make collectionForm to pass into put
            CollectionFormViewModel collectionForm = new CollectionFormViewModel()
            {
                Collection         = collection,
                ProjectCollections = new List <ProjectCollection>()
            };

            // Use a matching Id
            var collectionParamId = 1;

            // Spoof UserController
            var controller = new CollectionController(_fakeUserRepo.Object, _fakeCollectionRepo.Object, _fakeProjColRepo.Object);

            controller.ControllerContext             = new ControllerContext(); // Required to create the controller
            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = user
            };                                                                                 // Pretend the user is making a request to the controller

            // Attempt to Get this User's collections
            var response = controller.Put(collectionParamId, collectionForm);

            // Returns Ok
            Assert.IsType <NotFoundResult>(response);
        }
Пример #23
0
        public void Collection()
        {
            ILogger <CollectionController> _testlogger = null;

            using (var context = new AppDbContext(options, null))
            {
                var controller = new CollectionController(context, _testlogger);

                // Get all
                var result = controller.Get();
                // Assert
                var okResult = Assert.IsAssignableFrom <IEnumerable <Collection> >(result);
                var pgcount  = okResult.ToList().Count;
                Assert.Equal(2, pgcount);
                // Get by ID
                var result1   = controller.Get(1);
                var okResult1 = Assert.IsAssignableFrom <Collection>(result1);
                //var thisresult1 = okResult1.FirstOrDefault();
                Assert.Equal("collection type 1", result1.CollectionName);

                // test update
                var pg1 = new Collection {
                    CollectionID = 1, CollectionName = "collection type 1 upd"
                };
                controller.UpdateEntry(pg1);
                var result3 = controller.Get(1);
                //var thisresult3 = result3.FirstOrDefault();
                Assert.NotEqual("collection type 1", result3.CollectionName);
                Assert.Equal("collection type 1 upd", result3.CollectionName);

                // test delete
                var result4 = controller.Get(2);
                //var thisresult4 = result4.FirstOrDefault();
                Assert.Equal("collection type 2", result4.CollectionName);

                IActionResult result5    = controller.Delete(2);
                var           viewResult = Assert.IsType <Microsoft.AspNetCore.Mvc.OkResult>(result5);
                var           result6    = controller.Get(2);
                Assert.Null(result6);
            }
        }
        public void Get_Collection_For_Id_Not_In_Db_Returns_Not_Found()
        {
            // Spoof an authenticated user by generating a ClaimsPrincipal
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
                new Claim(ClaimTypes.NameIdentifier, "FIREBASE_USER1"),
            }, "TestAuthentication"));

            // Spoof UserController
            var controller = new CollectionController(_fakeUserRepo.Object, _fakeCollectionRepo.Object, _fakeProjColRepo.Object);

            controller.ControllerContext             = new ControllerContext(); // Required to create the controller
            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = user
            };                                                                                 // Pretend the user is making a request to the controller

            // Attempt to get collection not in db
            var response = controller.GetByCollectionId(666);

            // Returns Ok
            Assert.IsType <NotFoundResult>(response);
        }
        public void Registered_User_Can_Get_Collections()
        {
            // Spoof an authenticated user by generating a ClaimsPrincipal
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
                new Claim(ClaimTypes.NameIdentifier, "FIREBASE_USER1"),
            }, "TestAuthentication"));

            // Spoof UserController
            var controller = new CollectionController(_fakeUserRepo.Object, _fakeCollectionRepo.Object, _fakeProjColRepo.Object);

            controller.ControllerContext             = new ControllerContext(); // Required to create the controller
            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = user
            };                                                                                 // Pretend the user is making a request to the controller

            // Attempt to Get this User's posts
            var response = controller.GetByUserId();

            // Returns Ok
            Assert.IsType <OkObjectResult>(response);
        }
        public void Collection_Owner_Can_Delete_A_Collection()
        {
            // Spoof an authenticated user by generating a ClaimsPrincipal
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
                new Claim(ClaimTypes.NameIdentifier, "FIREBASE_USER2"),
            }, "TestAuthentication"));

            // Spoof UserController
            var controller = new CollectionController(_fakeUserRepo.Object, _fakeCollectionRepo.Object, _fakeProjColRepo.Object);

            controller.ControllerContext             = new ControllerContext(); // Required to create the controller
            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = user
            };                                                                                 // Pretend the user is making a request to the controller

            // Attempt to get this user's collection
            var response = controller.Delete(2);

            // Returns Ok
            Assert.IsType <NoContentResult>(response);
        }
Пример #27
0
        public void Can_Send_Pagination_View_Model()
        {
            // Организация (arrange)
            Mock <ICollectionRepository> mock = new Mock <ICollectionRepository>();

            mock.Setup(m => m.Collections).Returns(new List <Collection>
            {
                new Collection {
                    CollectionId = 1, Name = "Игра1"
                },
                new Collection {
                    CollectionId = 2, Name = "Игра2"
                },
                new Collection {
                    CollectionId = 3, Name = "Игра3"
                },
                new Collection {
                    CollectionId = 4, Name = "Игра4"
                },
                new Collection {
                    CollectionId = 5, Name = "Игра5"
                }
            });
            CollectionController controller = new CollectionController(mock.Object);

            controller.pageSize = 3;

            // Act
            CollectionsListViewModel result
                = (CollectionsListViewModel)controller.List(null, 2).Model;

            // Assert
            PagingInfo pageInfo = result.PagingInfo;

            Assert.AreEqual(pageInfo.CurrentPage, 2);
            Assert.AreEqual(pageInfo.ItemsPerPage, 3);
            Assert.AreEqual(pageInfo.TotalItems, 5);
            Assert.AreEqual(pageInfo.TotalPages, 2);
        }
        public void SetUp()
        {
            mockUserManager = AppMockHelper.GetMockUserManager();
            mockUserManager.Setup(u => u.FindByIdAsync(It.IsAny <string>())).ReturnsAsync(new ApplicationUser {
                MuseumId = 1
            });

            mockCreatePieceViewModelFactory = new Mock <ICreatePieceViewModelFactory>();
            mockCreatePieceViewModelFactory.Setup(c => c.Create(It.IsAny <string>()))
            .Returns(new CreatePieceViewModel());

            mockPieceListQuery = new Mock <IGetPieceListQuery>();
            mockPieceListQuery.Setup(q => q.Execute(It.IsAny <int>()))
            .Returns(new List <PieceModel>());

            mockPieceQuery = new Mock <IGetPieceQuery>();
            mockPieceQuery.Setup(q => q.Execute(It.IsAny <int>()))
            .Returns(new PieceModel());

            mockCreatePieceCommand = new Mock <ICreatePieceCommand>();

            mockValidator = new Mock <ICreatePieceViewModelValidator>();

            collectionController = new CollectionController(
                mockUserManager.Object,
                mockCreatePieceViewModelFactory.Object,
                mockPieceListQuery.Object,
                mockPieceQuery.Object,
                mockCreatePieceCommand.Object,
                mockValidator.Object);

            collectionController.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = new ClaimsPrincipal()
                }
            };
        }
        public void Anonymous_User_Can_Not_Get_Collections()
        {
            // Spoof an authenticated user by generating a ClaimsPrincipal
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
                new Claim(ClaimTypes.NameIdentifier, "FIREBASE_USER666"),
            }, "TestAuthentication"));

            // Spoof UserController
            var controller = new CollectionController(_fakeUserRepo.Object, _fakeCollectionRepo.Object, _fakeProjColRepo.Object);

            controller.ControllerContext             = new ControllerContext(); // Required to create the controller
            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = user
            };                                                                                 // Pretend the user is making a request to the controller

            // Attempt to Get this User's collections
            var response = controller.GetByUserId();

            // Returns Ok
            Assert.IsType <NotFoundResult>(response);
            // Verify we never called the repo method
            _fakeCollectionRepo.Verify(r => r.Get(It.IsAny <int>()), Times.Never());
        }
        public void Collection_NonOwner_Can_Not_Delete_A_Collection()
        {
            // Spoof an authenticated user by generating a ClaimsPrincipal
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] {
                new Claim(ClaimTypes.NameIdentifier, "FIREBASE_USER1"),
            }, "TestAuthentication"));

            // Spoof UserController
            var controller = new CollectionController(_fakeUserRepo.Object, _fakeCollectionRepo.Object, _fakeProjColRepo.Object);

            controller.ControllerContext             = new ControllerContext(); // Required to create the controller
            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = user
            };                                                                                 // Pretend the user is making a request to the controller

            // Attempt to get someone's else's collection
            var response = controller.Delete(2);

            // Returns Ok
            Assert.IsType <NotFoundResult>(response);
            // Verify we never called the repo method
            _fakeCollectionRepo.Verify(r => r.Delete(It.IsAny <CollectionDetailsViewModel>()), Times.Never());
        }
Пример #31
0
    public void UpdateCollectedItems(CollectionController item)
    {
        collectedItemNames.Add(item.item.name);

        foreach (string i in collectedItemNames)
        {
            switch (i)
            {
            case ("Boot"):
                bootCollected = true;
                break;

            case ("Gun"):
                gunCollected = true;
                break;
            }
        }

        if (bootCollected && gunCollected)
        {
            gameObject.GetComponent <AttackController>().changeFireRate(0.25f);
        }
    }