public void ShouldGetCorrectVersionNumber()
        {
            VNCAppUpdater sut          = new VNCAppUpdater(GetAppUpdateDetail());
            var           latestVerion = sut.GetLatestVesrion();

            Assert.AreEqual("1.0.0.11", latestVerion);
        }
        public void ShouldThrowExceptionWhenSourceIsNotReachableVnc()
        {
            var fileGateway = Mock.Create <IFileGateway>();

            Mock.Arrange(() => fileGateway.ReadAllText(Arg.AnyString)).Throws(new IOException("Unit Test"));

            var sut = new VNCAppUpdater(new AppUpdateDetail(string.Empty, string.Empty), fileGateway);

            Assert.Throws <LocationNotReachableException>(() => sut.GetLatestVesrion());
        }
        public void ShouldUpdateApp()
        {
            VNCAppUpdater sut = GetAppUpdateDetail();

            sut.UpdateApp();

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

            Assert.IsNull(foundKya);

            Assert.AreEqual(Directory.GetFiles(sut.AppUpdateDetail.LocalDestination).Count(), Directory.GetFiles(sut.AppUpdateDetail.RemoteSource).Count() - 1);
        }
        public void ShouldGetCorrectVersionNumberVnc()
        {
            var fileGateway = Mock.Create <IFileGateway>();

            Mock.Arrange(() => fileGateway.ReadAllText(Arg.AnyString)).Returns(() => "1.0.0.11").OccursOnce();

            var sut          = new VNCAppUpdater(new AppUpdateDetail(string.Empty, string.Empty), fileGateway);
            var latestVerion = sut.GetLatestVesrion();

            Assert.AreEqual("1.0.0.11", latestVerion);

            Mock.AssertAll(fileGateway);
        }
        public void ShouldUpdateApp()
        {
            var           vncAppUpdateDetail = GetAppUpdateDetail(1);
            VNCAppUpdater sut = new VNCAppUpdater(vncAppUpdateDetail);

            var exludeFile = "Version.txt";

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

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

            Assert.IsNull(foundKya);

            Assert.AreEqual(Directory.GetFiles(vncAppUpdateDetail.Destination).Count(), Directory.GetFiles(vncAppUpdateDetail.Source).Count() - 1);
        }
        public void ShouldUpdateAppVnc()
        {
            var fileGateway = Mock.Create <IFileGateway>();

            var copyedFiles = new List <string>();

            Mock.Arrange(() => fileGateway.GetFiles(Arg.AnyString)).Returns(() => new[] { "file1", "excludeme" }).OccursOnce();

            Mock.Arrange(() => fileGateway.Copy(Arg.AnyString, Arg.AnyString)).DoInstead((string source, string destination) => { copyedFiles.Add(source); }).OccursOnce();

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

            sut.UpdateApp();

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

            Assert.IsNull(foundKya);
            Assert.AreEqual(copyedFiles.Count, 1);
            Assert.AreEqual(copyedFiles.FirstOrDefault(), "file1");
            Mock.AssertAll(fileGateway);
        }
        public void ShouldThrowExceptionWhenSourceIsNotReachable()
        {
            var sut = new VNCAppUpdater(new AppUpdateDetail(@"\\10.131.70.129\StausMaker", ""));

            Assert.Throws <LocationNotReachable>(() => sut.GetLatestVesrion());
        }