public void SketchFileWithoutCompatibilityVersionDoesNotFail()
        {
            // The first sketch-files in the open format doesn't seem to have compatibilityVersion field
            var archive    = Substitute.For <ISketchArchive>();
            var appVersion = 3.14;
            var version    = 91;

            var json =
                @"{
				'appVersion': '"                 + appVersion + @"',
				'build': 45422,
				'variant': 'NONAPPSTORE',
				'version': '"                 + version + @"'
			}"            ;

            using (var jsonStream = new MemoryStream(Encoding.ASCII.GetBytes(json))) {
                archive.OpenFile("meta.json")
                .Returns(jsonStream);

                var log = new MessageListLogger();

                CompatibilityChecker.Check("dummy.sketch", archive, log);

                Assert.AreEqual(1, log.ErrorsAndWarnings().Count);
                Assert.AreEqual(3, log.Messages.Count);
                Assert.That(log.ErrorsAndWarnings().First(),
                            Does.StartWith("WARNING:" + "\t" + "The sketch file was created with an older version"));
            }
        }
        public void IsCultureInsensitive()
        {
            var archive             = Substitute.For <ISketchArchive>();
            var appVerion           = 3.14;
            var version             = CompatibilityChecker.SketchCompatibilityVersion;
            var compatibiltyVersion = version;

            var json = GenerateMetaJson(appVerion, compatibiltyVersion, version);

            using (var jsonStream = new MemoryStream(Encoding.ASCII.GetBytes(json)))
            {
                archive.OpenFile("meta.json")
                .Returns(jsonStream);

                var log = new MessageListLogger();

                Thread.CurrentThread.CurrentCulture = new CultureInfo("nb-NO");
                CompatibilityChecker.Check("dummy.sketch", archive, log);
            }
        }
        public void SketchFileProducedWithOlderVersionThanSupportedGivesWarning()
        {
            var archive             = Substitute.For <ISketchArchive>();
            var appVerion           = 3.14;
            var version             = CompatibilityChecker.SketchCompatibilityVersion - 3;
            var compatibiltyVersion = version;

            var json = GenerateMetaJson(appVerion, compatibiltyVersion, version);

            using (var jsonStream = new MemoryStream(Encoding.ASCII.GetBytes(json))) {
                archive.OpenFile("meta.json")
                .Returns(jsonStream);

                var log = new MessageListLogger();

                CompatibilityChecker.Check("dummy.sketch", archive, log);

                Assert.AreEqual(1, log.ErrorsAndWarnings().Count);
                Assert.AreEqual(3, log.Messages.Count);
                Assert.That(log.ErrorsAndWarnings().First(),
                            Does.StartWith("WARNING:" + "\t" + "The sketch file was created with an older version"));
            }
        }