Exemplo n.º 1
0
        public void ShouldUpdateAppGit()
        {
            List <object> objectArr = new List <object>();

            objectArr.Add(new Dictionary <string, object> {
                { "name", "file1" }, { "download_url", "file1url" }
            });
            objectArr.Add(new Dictionary <string, object> {
                { "name", "excludeme" }
            });

            var copyedFiles = new List <string>();

            var httpEngine = Mock.Create <IHttpEngine>();

            Mock.Arrange(() => httpEngine.GetHttpResponseObjectAsync(Arg.AnyString)).Returns(() => Task.Run(() => (object)objectArr.ToArray())).OccursOnce();

            Mock.Arrange(() => httpEngine.DownLoadFileAsync(Arg.AnyString, Arg.AnyString)).DoInstead((string url, string downloadFilePath) => { copyedFiles.Add(url); }).OccursOnce();

            var sut = new GitHubAppUpdater(httpEngine, new AppUpdateDetail(string.Empty, string.Empty, new[] { "excludeme" }));

            sut.UpdateApp();

            var foundKya = copyedFiles.FirstOrDefault(x => x.Equals("excludeme"));

            Assert.IsNull(foundKya);
            Assert.AreEqual(copyedFiles.Count, objectArr.Count - 1);
            Assert.AreEqual(copyedFiles.FirstOrDefault(), "file1url");
            Mock.AssertAll(httpEngine);
        }
Exemplo n.º 2
0
        public void ShouldUpdateAppGit()
        {
            var gitHub = Mock.Create <IGitHub>();

            Mock.Arrange(() => gitHub.PullFolderServer(string.Empty, string.Empty, null)).IgnoreArguments().OccursOnce();
            var sut = new GitHubAppUpdater(gitHub, new AppUpdateDetail(string.Empty, string.Empty, Enumerable.Empty <string>()));

            sut.UpdateApp();

            Mock.AssertAll(gitHub);
        }
Exemplo n.º 3
0
        public void ShouldUpdateApp()
        {
            var appUpdateDetail = GetAppUpdateDetail();

            var sut = new GitHubAppUpdater(_gitHub, appUpdateDetail);

            sut.UpdateApp();

            var foundKya = Directory.GetFiles(appUpdateDetail.LocalDestination).FirstOrDefault(x => Path.GetFileName(x).Equals(appUpdateDetail.ExcludeFiles.FirstOrDefault()));

            Assert.IsNull(foundKya);

            var files = (object[])new HttpEngine().GetHttpResponseObjectAsync(appUpdateDetail.RemoteSource).Result;

            Assert.AreEqual(Directory.GetFiles(appUpdateDetail.LocalDestination).Count(), files.Count() - 1);
        }
Exemplo n.º 4
0
        public void ShouldUpdateApp()
        {
            var appUpdateDetail = GetAppUpdateDetail();

            var sut = new GitHubAppUpdater(appUpdateDetail);

            var exludeFile = "Version.txt";

            sut.UpdateApp(new[] { exludeFile });

            var foundKya = Directory.GetFiles(appUpdateDetail.Destination).FirstOrDefault(x => Path.GetFileName(x).Equals(exludeFile));

            Assert.IsNull(foundKya);

            var files = (object[])new HttpEngine().GetHttpResponseObjectAsync(appUpdateDetail.Source).Result;

            Assert.AreEqual(Directory.GetFiles(appUpdateDetail.Destination).Count(), files.Count() - 1);
        }