示例#1
0
        public void EditProjectTest()
        {
            Entities db = new Entities();
            // Arrange
            TempDataDictionary tempData = new TempDataDictionary();
            var researcherToDel         = DatabaseInsert.AddTestUser("Researcher", db);

            tempData["ActiveUser"] = researcherToDel;
            var pToDel = DatabaseInsert.AddTestProject(researcherToDel, db);
            ResearchController controller = new ResearchController
            {
                TempData = tempData
            };

            // Act
            ViewResult result = controller.EditProject(pToDel.projectID) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("EditProject", result.ViewName);
            Assert.IsNotNull(result.TempData["ActiveUser"]);
            Assert.IsNotNull(result.Model);
            Assert.AreEqual(((project)result.Model).projectID, pToDel.projectID);

            db.projects.Remove(pToDel);
            db.users.Remove(researcherToDel);
            db.SaveChanges();
        }
示例#2
0
        public void ResearcherIndexTest()
        {
            Entities db = new Entities();

            // Arrange
            TempDataDictionary tempData = new TempDataDictionary();
            var researcherToDel         = DatabaseInsert.AddTestUser("Researcher", db);

            var projectToDel = DatabaseInsert.AddTestProject(researcherToDel, db);

            tempData["ActiveUser"] = researcherToDel;

            ResearchController controller = new ResearchController();

            controller.TempData = tempData;

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Index", result.ViewName);
            Assert.IsNotNull(result.TempData["ActiveUser"]);
            Assert.IsNotNull(result.Model);
            Assert.AreEqual(((List <project>)result.Model).First().projectID, projectToDel.projectID);

            db.projects.Remove(projectToDel);
            db.users.Remove(researcherToDel);
            db.SaveChanges();
        }
示例#3
0
        public void ResearcherDetailsTest()
        {
            Entities db = new Entities();

            // Arrange
            TempDataDictionary tempData = new TempDataDictionary();
            var researcherToDel         = DatabaseInsert.AddTestUser("Researcher", db);

            var projectToDel = DatabaseInsert.AddTestProject(researcherToDel, db);

            tempData["ActiveUser"] = researcherToDel;

            ResearchController controller = new ResearchController();

            controller.TempData = tempData;

            // Act
            ViewResult result = controller.Details(projectToDel.projectID) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Details", result.ViewName);
            Assert.IsNotNull(result.TempData["ActiveUser"]);
            Assert.IsNotNull(result.Model);
            Assert.AreEqual(((project)result.Model).projectID, projectToDel.projectID);
            Assert.AreEqual(((project)result.Model).pName, projectToDel.pName);
            Assert.AreEqual(((project)result.Model).pDesc, projectToDel.pDesc);
            Assert.AreEqual(((project)result.Model).pAbstract, projectToDel.pAbstract);
            Assert.AreEqual(((project)result.Model).projectFile, projectToDel.projectFile);
            Assert.AreEqual(((project)result.Model).projectStage, projectToDel.projectStage);

            db.projects.Remove(projectToDel);
            db.users.Remove(researcherToDel);
            db.SaveChanges();
        }
        public async Task RetrieveInvalidRecord_DetailsCorrect()
        {
            // Arrange
            var testUrl = "www.pmichaels.net";
            var options = new DbContextOptionsBuilder <ResearchContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .EnableSensitiveDataLogging()
                          .Options;
            var researchContext    = new ResearchContext(options);
            var researchController = new ResearchController(researchContext);
            var research           = new Research()
            {
                Id        = 1,
                DateSaved = new DateTime(2018, 10, 24),
                Note      = "Useful site for programming and tech information",
                Read      = false,
                Url       = testUrl
            };

            var createResult = await researchController.Create(research);

            // Act
            var detailsResult = await researchController.Details(2);

            // Assert
            Assert.IsType <NotFoundResult>(detailsResult);
        }
 private void SetResearchButtonCallback(ResearchController researchController, ResearchTree researchTree, GameObject button)
 {
     button.GetComponent <Button>().onClick.AddListener(() =>
     {
         researchController.DoResearch(researchTree.NextNode);
     });
 }
示例#6
0
    // Start is called before the first frame update
    void Start()
    {
        Scene currentScene = SceneManager.GetActiveScene();

        if (currentScene.name != "Main Menu")
        {
            team        = GameObject.Find("Faction");
            player      = GameObject.FindGameObjectWithTag("Player");
            playerAudio = GameObject.FindGameObjectWithTag("Main Audio").GetComponent <AudioSource>();
            UI          = player.GetComponent <UIController>();
            RC          = team.GetComponent <ResearchController>();
            PM          = GameObject.Find("GameMenu").GetComponent <PauseMenu>();

            // progressIcon = GameObject.Find("ProgressIcon").GetComponent<Image>();
            // foundationScript = selectedObj.GetComponent<FoundationController>();
            // progressIcon.sprite = foundationScript.buildingPrefab.GetComponent<BuildingController>().icon;
            unitIcon               = GameObject.Find("UnitIcon");
            BuildingProgressBar    = GameObject.Find("BuildingProgressBar");
            BuildingProgressSlider = BuildingProgressBar.GetComponent <Slider>();

            rotation = Camera.main.transform.rotation;
            cam      = Camera.main;
            minimap  = GameObject.Find("Minimap").GetComponent <Camera>();
            // RESEARCH COROUTINES - only one working
            StartCoroutine(UpdatePanels());
        }
    }
示例#7
0
 public void Awake()
 {
     if (rc == null)
     {
         rc = ResearchController.Instance;
     }
 }
示例#8
0
    public void Awake()
    {
        works = new List <Vector3>();

        agents  = new List <AgentController>();
        trash   = new List <AgentController>();
        created = new List <AgentController>();

        Access = true;

        if (mc == null)
        {
            mc = MovementController.Instance;
        }
        if (rc == null)
        {
            rc = ResearchController.Instance;
        }

        Range = UnityEngine.Random.Range(0, MaxRange);
        this.gameObject.transform.localScale = new Vector3(Range * 0.1f, 1.0f, Range * 0.1f);

        works.Add(RandomPos);

        School = RandomPos;
        works.Add(School);

        Hospital = RandomPos;
        works.Add(Hospital);

        Shop = RandomPos;
        works.Add(Shop);

        Church = RandomPos;
    }
示例#9
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject team = GameObject.Find("Faction");

        RC = team.GetComponent <ResearchController>();
        StartCoroutine(ResourceTick());
    }
示例#10
0
 // Start is called before the first frame update
 void Start()
 {
     player      = GameObject.FindGameObjectWithTag("Player");
     team        = GameObject.Find("Faction");
     RC          = team.GetComponent <ResearchController>();
     playerunits = GameObject.FindGameObjectsWithTag("Selectable");
 }
示例#11
0
 public void ConductGET_ReturnsViewResult_WithProperlyFilteredListsOfMaterials()
 {
     #region ARRANGE
     var controller = new ResearchController(
         mockMaterialsService.Object,
         mockEmployeesService.Object,
         mockLogger.Object);
     mockMaterialsService.Setup(s => s.GetMaterials())
     .Returns(new Material[]
     {
         new Material(EElement.B, EForm.Pellets, 1),                             //PLATE
         new Material(EElement.Mn, EForm.Rods, 1),                               //ADDITIVE
         new Material(EElement.Nb, EForm.Sheets, 1)                              //ADDITIVE,BASE
     });
     #endregion
     #region ACT
     var actionResult = controller.Conduct();
     #endregion
     #region ASSERT
     var viewResult = Assert.IsType <ViewResult>(actionResult);
     var model      = Assert.IsAssignableFrom <ResearchViewModel>(viewResult.ViewData.Model);
     Assert.Equal(2, model.AdditionalMaterials.Count());
     Assert.Single(model.BaseMaterials);
     #endregion
 }
示例#12
0
        public void ResearcherSignTest()
        {
            Entities db = new Entities();

            // Arrange
            TempDataDictionary tempData = new TempDataDictionary();
            var ResearcherToDel         = DatabaseInsert.AddTestUser("Researcher", db);

            var projectToDel = DatabaseInsert.AddTestProject(ResearcherToDel, db, "Awaiting further action from Researcher");

            tempData["ActiveUser"] = ResearcherToDel;

            ResearchController controller = new ResearchController();

            controller.TempData = tempData;

            // Act
            ViewResult result = (ViewResult)controller.Sign(projectToDel.projectID);
            Entities   db2    = new Entities();

            db2.changes.Remove(db2.projects.Find(projectToDel.projectID).changes.First());
            db2.projects.Remove(db2.projects.Find(projectToDel.projectID));
            db2.users.Remove(db2.users.Find(ResearcherToDel.userID));
            db2.SaveChanges();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Index", result.ViewName);
            Assert.IsNotNull(result.TempData["ActiveUser"]);
            Assert.IsNotNull(result.Model);
            Assert.AreEqual(((List <project>)result.Model).First().projectID, projectToDel.projectID);
        }
示例#13
0
        public void DownloadProjectTest()
        {
            Entities db = new Entities();
            // Arrange
            TempDataDictionary tempData = new TempDataDictionary();
            var researcherToDel         = DatabaseInsert.AddTestUser("Researcher", db);

            tempData["ActiveUser"] = researcherToDel;
            var pToDel = DatabaseInsert.AddTestProject(researcherToDel, db);
            ResearchController controller = new ResearchController
            {
                TempData = tempData
            };

            // Act
            FileResult result = controller.Download(pToDel.projectID) as FileResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(pToDel.pName + "-ExpenditureFile" + Path.GetExtension(pToDel.projectFile), result.FileDownloadName);
            Assert.AreEqual("application/" + Path.GetExtension(pToDel.projectFile), result.ContentType);

            db.projects.Remove(pToDel);
            db.users.Remove(researcherToDel);
            db.SaveChanges();
        }
示例#14
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
示例#15
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");
        GameObject team   = GameObject.Find("Faction");

        RM = team.GetComponent <ResourceManager>();
        RC = team.GetComponent <ResearchController>();

        // Starts the resource tick (means its true)
        BuildingProgressPanel = GameObject.Find("BuildingProgressPanel").GetComponent <CanvasGroup>();
        StartCoroutine(BuildTick());
    }
示例#16
0
        public void GetIndex_RedirectsToResearchGate()
        {
            // arrange
            var sut = new ResearchController();

            // act
            var result = sut.Index() as RedirectResult;

            // assert
            Assert.Equal("https://www.researchgate.net/profile/Bart_Vaerenberg", result.Url);
            Assert.False(result.Permanent);
        }
    private void GenerateResearches()
    {
        for (int i = 0; i < _researches.Count; i++)
        {
            GameObject newResearchGameObject = Instantiate(researchPrefab);
            newResearchGameObject.transform.SetParent(gameObject.transform);
            newResearchGameObject.transform.localScale = new Vector3(1, 1, 1);

            ResearchController researchController = newResearchGameObject.GetComponent <ResearchController>();
            researchController.GetResearchModel().SetResearch(_researches[i]);
            researchController.GetResearchModel().SetPanelController(this);
        }
    }
示例#18
0
    public void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        initalTardiness   = tardiness;
        initialAlertLevel = alertLevel;
    }
示例#19
0
    // Start is called before the first frame update
    void Start()
    {
        player                = GameObject.FindGameObjectWithTag("Player");
        team                  = GameObject.Find("Faction");
        UI                    = player.GetComponent <UIController>();
        RM                    = team.GetComponent <ResourceManager>();
        RC                    = team.GetComponent <ResearchController>();
        inputScript           = player.GetComponent <InputManager>();
        BuildingProgressPanel = GameObject.Find("BuildingProgressPanel").GetComponent <CanvasGroup>();
        BuildingActionPanel   = GameObject.Find("BuildingActions").GetComponent <CanvasGroup>();

        // Progress bar
        BuildingProgressBar    = GameObject.Find("BuildingProgressBar");
        BuildingProgressSlider = BuildingProgressBar.GetComponent <Slider>();
    }
示例#20
0
    public void Start()
    {
        mc       = MovementController.Instance;
        ic       = IllnessController.Instance;
        rc       = ResearchController.Instance;
        mc.Scale = MapScale;

        CitySpawner();
        AgentSpawner.Instance.Spawn();
        Tick();

        List <City> temp = cities.Where(e => e.Agents > 0).ToList();

        temp[UnityEngine.Random.Range(0, temp.Count)].RandomAgent.Illness = true;
    }
示例#21
0
        public async Task ConductPOST_ReturnsBadRequest_WhenInputDataIsFaulty(string data)
        {
            #region ARRANGE
            var controller = new ResearchController(
                mockMaterialsService.Object,
                mockEmployeesService.Object,
                mockLogger.Object);
            #endregion
            #region ACT
            var actionResult = await controller.Conduct(data);

            #endregion
            #region ASSERT
            var badRequestResult = Assert.IsType <BadRequestObjectResult>(actionResult);
            #endregion
        }
示例#22
0
    public override void OnInspectorGUI()
    {
        ResearchController rsc = target as ResearchController;

        if (GUILayout.Button("Refresh"))
        {
            rsc.EditorRefresh();
            SceneView.RepaintAll();
        }
        if (GUILayout.Button("Generate Years"))
        {
            rsc.EditorGenerateYears();
            SceneView.RepaintAll();
        }
        DrawDefaultInspector();
    }
示例#23
0
    // Start is called before the first frame update
    void Start()
    {
        Scene currentScene = SceneManager.GetActiveScene();

        if (currentScene.name != "Main Menu")
        {
            team        = GameObject.Find("Faction");
            player      = GameObject.FindGameObjectWithTag("Player");
            playerAudio = GameObject.FindGameObjectWithTag("Main Audio").GetComponent <AudioSource>();
            RM          = team.GetComponent <ResourceManager>();
            RC          = team.GetComponent <ResearchController>();
            IM          = player.GetComponent <InputManager>();
            UC          = GetComponent <UnitController>();
            agent       = GetComponent <NavMeshAgent>();
        }
    }
示例#24
0
        public void EditProjectRedirectTest()
        {
            Entities db = new Entities();

            // Arrange
            TempDataDictionary tempDataRIS        = new TempDataDictionary();
            TempDataDictionary tempDataResearcher = new TempDataDictionary();

            var RISToDel        = DatabaseInsert.AddTestUser("RIS", db);
            var ResearcherToDel = DatabaseInsert.AddTestUser("Researcher", db);
            var pToDel          = DatabaseInsert.AddTestProject(ResearcherToDel, db);
            var pToDelRIS       = DatabaseInsert.AddTestProject(RISToDel, db);


            tempDataRIS["ActiveUser"]        = RISToDel;
            tempDataResearcher["ActiveUser"] = ResearcherToDel;

            ResearchController RISResearchController = new ResearchController();

            RISResearchController.TempData = tempDataRIS;

            ResearchController ResearchController = new ResearchController();

            ResearchController.TempData = tempDataResearcher;

            // Act
            RedirectToRouteResult resultRIS        = (RedirectToRouteResult)RISResearchController.EditProject(pToDelRIS.projectID) as RedirectToRouteResult;
            ViewResult            resultResearcher = (ViewResult)ResearchController.EditProject(pToDel.projectID) as ViewResult;

            db.projects.Remove(pToDelRIS);
            db.projects.Remove(pToDel);
            db.users.Remove(RISToDel);
            db.users.Remove(ResearcherToDel);
            db.SaveChanges();

            // Assert 'Other User'
            Assert.IsNotNull(resultRIS);
            Assert.IsTrue(resultRIS.RouteValues.ContainsKey("action"));
            Assert.IsTrue(resultRIS.RouteValues.ContainsKey("controller"));
            Assert.AreEqual("ControllerChange", resultRIS.RouteValues["action"].ToString());
            Assert.AreEqual("Home", resultRIS.RouteValues["controller"].ToString());

            //Assert Researcher
            Assert.IsNotNull(resultResearcher);
            Assert.AreEqual("EditProject", resultResearcher.ViewName);
        }
示例#25
0
        public async Task ConductPOST_ReturnsBadRequest_WhenInsufficientMaterialQuantity(string data)
        {
            #region ARRANGE
            var controller = new ResearchController(
                mockMaterialsService.Object,
                mockEmployeesService.Object,
                mockLogger.Object);
            mockMaterialsService.Setup(s => s.GetMaterial("Al", 2))
            .Returns(new Material(EElement.Al, EForm.Slabs, 0));
            #endregion
            #region ACT
            var actionResult = await controller.Conduct(data);

            #endregion
            #region ASSERT
            var badRequestResult = Assert.IsType <BadRequestObjectResult>(actionResult);
            #endregion
        }
示例#26
0
        public async Task ConductPOST_ReturnsSuccessMessage_WhenAllValidationsPassed(string data)
        {
            #region ARRANGE
            var controller = new ResearchController(
                mockMaterialsService.Object,
                mockEmployeesService.Object,
                mockLogger.Object);
            mockMaterialsService.Setup(s => s.GetMaterial("Fe", 3))
            .Returns(new Material(EElement.Fe, EForm.Bars, 5));
            mockMaterialsService.Setup(s => s.GetMaterial("Mn", 1))
            .Returns(new Material(EElement.Mn, EForm.Pellets, 3.3));
            var composition = new Dictionary <string, double>()
            {
                { "Fe", 60.3639045979838 }, { "Mn", 39.6360954020162 }
            };
            mockMaterialsService.Setup(s => s.CreateAlloyAsync(composition, 393.75676M))
            .ReturnsAsync(new Alloy()
            {
                Composition  = "Fe60.36Mn39.64",
                ResearchCost = 393.75676M
            });
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim("ProfileId", "1"),
                new Claim(ClaimTypes.NameIdentifier, "1")
            }));
            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = user
                }
            };
            mockEmployeesService.Setup(s => s.UpdateLastWorkedAsync("1"))
            .Returns(Task.CompletedTask);
            #endregion
            #region ACT
            var actionResult = await controller.Conduct(data);

            #endregion
            #region ASSERT
            var jsonResult = Assert.IsType <BadRequestObjectResult>(actionResult);
            #endregion
        }
示例#27
0
        public void DownloadProjectRedirectTest()
        {
            Entities db = new Entities();

            // Arrange
            TempDataDictionary tempDataRIS        = new TempDataDictionary();
            TempDataDictionary tempDataResearcher = new TempDataDictionary();

            var RISToDel        = DatabaseInsert.AddTestUser("RIS", db);
            var ResearcherToDel = DatabaseInsert.AddTestUser("Researcher", db);
            var pToDel          = DatabaseInsert.AddTestProject(ResearcherToDel, db);
            var pToDelRIS       = DatabaseInsert.AddTestProject(RISToDel, db);


            tempDataRIS["ActiveUser"]        = RISToDel;
            tempDataResearcher["ActiveUser"] = ResearcherToDel;

            ResearchController RISResearchController = new ResearchController();

            RISResearchController.TempData = tempDataRIS;

            ResearchController ResearchController = new ResearchController();

            ResearchController.TempData = tempDataResearcher;

            // Act
            FileResult resultRIS        = (FileResult)RISResearchController.Download(pToDelRIS.projectID) as FileResult;
            FileResult resultResearcher = ResearchController.Download(pToDel.projectID) as FileResult;

            db.projects.Remove(pToDelRIS);
            db.projects.Remove(pToDel);
            db.users.Remove(RISToDel);
            db.users.Remove(ResearcherToDel);
            db.SaveChanges();

            // Assert 'Other User'
            Assert.IsNull(resultRIS);

            //Assert Researcher
            Assert.IsNotNull(resultResearcher);
            Assert.AreEqual(pToDel.pName + "-ExpenditureFile" + Path.GetExtension(pToDel.projectFile), resultResearcher.FileDownloadName);
            Assert.AreEqual("application/" + Path.GetExtension(pToDel.projectFile), resultResearcher.ContentType);
        }
示例#28
0
        public async Task ConductPOST_ReturnsBadRequest_WhenBasePercentageIsTooLow(string data)
        {
            #region ARRANGE
            var controller = new ResearchController(
                mockMaterialsService.Object,
                mockEmployeesService.Object,
                mockLogger.Object);
            mockMaterialsService.Setup(s => s.GetMaterial("Fe", 3))
            .Returns(new Material(EElement.Fe, EForm.Bars, 999));
            mockMaterialsService.Setup(s => s.GetMaterial("Ni", 3))
            .Returns(new Material(EElement.Ni, EForm.Bars, 999));
            #endregion
            #region ACT
            var actionResult = await controller.Conduct(data);

            #endregion
            #region ASSERT
            var badRequestResult = Assert.IsType <BadRequestObjectResult>(actionResult);
            #endregion
        }
示例#29
0
    // Start is called before the first frame update
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
        team   = GameObject.Find("Faction");
        UI     = player.GetComponent <UIController>();
        RM     = team.GetComponent <ResourceManager>();
        RC     = team.GetComponent <ResearchController>();

        anim          = GetComponent <Animator>();
        agent         = GetComponent <NavMeshAgent>();
        UnitSelection = GetComponent <UnitSelection>();
        archer        = GetComponent <ArcherController>();
        wizard        = GetComponent <WizardController>();
        if (archer)
        {
            arrowPrefab = archer.arrow;
        }
        if (wizard)
        {
            fireballPrefab = wizard.fireball;
        }
    }
示例#30
0
        public void CreateProjectTest()
        {
            Entities db = new Entities();
            // Arrange
            TempDataDictionary tempData = new TempDataDictionary();
            var researcherToDel         = DatabaseInsert.AddTestUser("Researcher", db);

            tempData["ActiveUser"] = researcherToDel;
            ResearchController controller = new ResearchController
            {
                TempData = tempData
            };

            // Act
            ViewResult result = controller.CreateProject() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("CreateProject", result.ViewName);
            Assert.IsNotNull(result.TempData["ActiveUser"]);
            db.users.Remove(researcherToDel);
        }