public void Should_ReturnRepositories_WhenServiceReturnsRepos()
        {
            // Arrange
            var fakeRepoServ = new Mock <IRepositoryService>();

            var repositories = new List <Repository>
            {
                new Repository {
                    Name = "Repo1", OpenPullRequests = 1, Url = "Test1"
                },
                new Repository {
                    Name = "Repo2", OpenPullRequests = 2, Url = "Test2"
                }
            };

            fakeRepoServ.Setup(o => o.GetAllRepositoriesForUser(It.IsAny <string>())).Returns(repositories);
            fakeRepoServ.Setup(o => o.GetOpenPullRequestsForRepositories(repositories, It.IsAny <string>()));
            var controller = new UsernameController(fakeRepoServ.Object);

            // Act
            var retRepos = controller.Get(It.IsAny <string>());

            // Assert
            Assert.IsNotNull(retRepos);
            Assert.AreEqual(2, retRepos.Count());
            Assert.AreEqual("Repo1", retRepos.ElementAt(0).Name);
            Assert.AreEqual(1, retRepos.ElementAt(0).OpenPullRequests);
            Assert.AreEqual("Test1", retRepos.ElementAt(0).Url);

            Assert.AreEqual("Repo2", retRepos.ElementAt(1).Name);
            Assert.AreEqual(2, retRepos.ElementAt(1).OpenPullRequests);
            Assert.AreEqual("Test2", retRepos.ElementAt(1).Url);
        }
 void Awake()
 {
     if (instance == null)
     {
         DontDestroyOnLoad(gameObject);
         instance = this;
     }
     else if (instance != null)
     {
         Destroy(gameObject);
     }
 }
        public void Should_Call_AllFunctions()
        {
            // Arrange
            var fakeRepoServ = new Mock <IRepositoryService>();

            fakeRepoServ.Setup(o => o.GetAllRepositoriesForUser(It.IsAny <string>())).Returns(new List <Repository>());
            UsernameController controller = new UsernameController(fakeRepoServ.Object);

            // Act
            controller.Get(It.IsAny <string>());

            // Assert
            fakeRepoServ.Verify(o => o.GetAllRepositoriesForUser(It.IsAny <string>()), Times.Once);
            fakeRepoServ.Verify(o => o.GetOpenPullRequestsForRepositories(new List <Repository>(), It.IsAny <string>()), Times.Once);
        }
示例#4
0
    void Start()
    {
        timePlayed       = 0.0f;
        healthController = GameObject.Find("HealthText").GetComponent <HealthController>();
        p = new Player();
        scoreController = GameObject.Find("ScoreText").GetComponent <ScoreController>();
        uC = GameObject.Find("Username").GetComponent <UsernameController>();

        float   dist       = transform.position.z - Camera.main.transform.position.z;
        Vector3 leftBound  = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, dist));
        Vector3 rightBound = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, dist));

        xMin = leftBound.x + 0.6f;
        xMax = rightBound.x - 0.6f;
    }
        public void Should_ReturnEmpty_WhenServiceDoesNotReturnRepos()
        {
            // Arrange
            var fakeRepoServ = new Mock <IRepositoryService>();

            var repositories = new List <Repository>();

            fakeRepoServ.Setup(o => o.GetAllRepositoriesForUser(It.IsAny <string>())).Returns(repositories);
            fakeRepoServ.Setup(o => o.GetOpenPullRequestsForRepositories(repositories, It.IsAny <string>()));
            var controller = new UsernameController(fakeRepoServ.Object);

            // Act
            var retRepos = controller.Get(It.IsAny <string>());

            // Assert
            Assert.IsNotNull(retRepos);
            Assert.AreEqual(0, retRepos.Count());
        }
示例#6
0
 void Start()
 {
     uC = GameObject.Find("Username").GetComponent <UsernameController>();
 }