コード例 #1
0
            public void GetsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();

                var client = new RepositoryCommitsClient(connection);

                client.Compare("owner", "repo", "base", "head");

                connection.Received()
                    .Get<CompareResult>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/compare/base...head"), null);
            }
コード例 #2
0
            public void EncodesUrl()
            {
                var connection = Substitute.For<IApiConnection>();

                var client = new RepositoryCommitsClient(connection);

                client.Compare("owner", "repo", "base", "shiftkey/my-cool-branch");

                connection.Received()
                    .Get<CompareResult>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/compare/base...shiftkey%2Fmy-cool-branch"), null);
            }
コード例 #3
0
            public void EnsureNonNullArguments()
            {
                var client = new RepositoryCommitsClient(Substitute.For<IApiConnection>());

                Assert.Throws<ArgumentNullException>(() => client.Compare(null, "repo", "base", "head"));
                Assert.Throws<ArgumentException>(() => client.Compare("", "repo", "base", "head"));

                Assert.Throws<ArgumentNullException>(() => client.Compare("owner", null, "base", "head"));
                Assert.Throws<ArgumentException>(() => client.Compare("owner", "", "base", "head"));

                Assert.Throws<ArgumentNullException>(() => client.Compare("owner", "repo", null, "head"));
                Assert.Throws<ArgumentException>(() => client.Compare("owner", "repo", "", "head"));

                Assert.Throws<ArgumentNullException>(() => client.Compare("owner", "repo", "base", null));
                Assert.Throws<ArgumentException>(() => client.Compare("owner", "repo", "base", ""));
            }