Beispiel #1
0
        public void Read_write_compare()
        {
            // Arrange
            var environment = FakeEnvironment.CreateWindowsEnvironment();
            var fileSystem  = new FakeFileSystem(environment);

            fileSystem.CreateFile("Data/Info.plist").SetContent(Resources.Info_plist.NormalizeLineEndings());
            fileSystem.CreateFile("Info_COPY.plist");
            var context = Substitute.For <ICakeContext>();

            context.FileSystem.Returns(fileSystem);
            context.Environment.Returns(environment);
            var expected = context.DeserializePlist("./Data/Info.plist");

            // Act
            PlistAliases.SerializePlist(context, "./Info_COPY.plist", expected);
            var dataCopy = context.DeserializePlist("./Info_COPY.plist");

            // Assert
            var a1 = ((Dictionary <string, object>)expected).ToArray();
            var a2 = ((Dictionary <string, object>)dataCopy).ToArray();

            // Assert.Equal is not working correct on dictionary. Therefore we iterate
            for (var i = 0; i < a1.Length; i++)
            {
                Assert.Equal(a1[i].Key, a2[i].Key);

                Assert.Equal(a1[i].Value, a2[i].Value);
            }
        }
Beispiel #2
0
        public void CanDeserializePlist()
        {
            // Arrange
            var plist = PlistAliases.DeserializePlist(null, new FilePath("Data/Issue3_Info.plist"));

            // Assert
            Assert.NotNull(plist);
        }
Beispiel #3
0
        public void Deserialize_missing_file_throws_exception()
        {
            var environment = FakeEnvironment.CreateWindowsEnvironment();
            var fileSystem  = new FakeFileSystem(environment);
            var context     = Substitute.For <ICakeContext>();

            context.FileSystem.Returns(fileSystem);
            context.Environment.Returns(environment);

            Assert.Throws <FileNotFoundException>(() => PlistAliases.DeserializePlist(context, "./file-doesnt-exist"));
        }
Beispiel #4
0
        public void Read_write_compare()
        {
            // Arrange
            var expected = PlistAliases.DeserializePlist(null, new FilePath("Data/Info.plist"));

            // Act
            PlistAliases.SerializePlist(null, new FilePath("Info_COPY.plist"), expected);
            var dataCopy = PlistAliases.DeserializePlist(null, new FilePath("Info_COPY.plist"));

            // Assert
            var a1 = ((Dictionary <string, object>)expected).ToArray();
            var a2 = ((Dictionary <string, object>)dataCopy).ToArray();

            // Assert.Equal is not working correct on dictionary. Therefore we iterate
            for (var i = 0; i < a1.Length; i++)
            {
                Assert.Equal(a1[i].Key, a2[i].Key);

                Assert.Equal(a1[i].Value, a2[i].Value);
            }
        }
Beispiel #5
0
        public void Deserialize_missing_file_throws_exception()
        {
            var file = new FilePath("it-dont-exist.plist");

            Assert.Throws <FileNotFoundException>(() => PlistAliases.DeserializePlist(null, file));
        }