Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
     });
 }
Ejemplo n.º 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());
        }
    }
Ejemplo n.º 7
0
 public void Awake()
 {
     if (rc == null)
     {
         rc = ResearchController.Instance;
     }
 }
Ejemplo n.º 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;
    }
Ejemplo n.º 9
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject team = GameObject.Find("Faction");

        RC = team.GetComponent <ResearchController>();
        StartCoroutine(ResourceTick());
    }
Ejemplo n.º 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");
 }
Ejemplo n.º 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
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 14
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
Ejemplo n.º 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());
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 18
0
    public void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        initalTardiness   = tardiness;
        initialAlertLevel = alertLevel;
    }
Ejemplo n.º 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>();
    }
Ejemplo n.º 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;
    }
Ejemplo n.º 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
        }
Ejemplo n.º 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();
    }
Ejemplo n.º 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>();
        }
    }
Ejemplo n.º 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);
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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;
        }
    }
Ejemplo n.º 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);
        }