Пример #1
0
        public void Name_WithFile_ReturnName()
        {
            var sut = new DummyResourceFileHandlerBase(_myfileTxt);

            var name = sut.Name;

            Assert.That(name, Is.EqualTo(_myfileTxt));
        }
Пример #2
0
        public void Add_KeyValues_SortedByKeys()
        {
            var sut = new DummyResourceFileHandlerBase(_myfileTxt);

            sut["b"] = "value";
            sut["a"] = "value";

            Assert.That(sut.ToArray()[0].Key, Is.EqualTo("a"));
        }
Пример #3
0
        public void Save_WihtoutBackup_NoValueReturned()
        {
            var sut = new DummyResourceFileHandlerBase(SourceFile);

            sut["secondline"] = "value";
            var backup = sut.Save(false);

            Assert.IsNull(backup);
        }
Пример #4
0
        public void SaveTwice_OldFile_NoDuplicateError()
        {
            var sut = new DummyResourceFileHandlerBase(SourceFile);

            sut["secondline"] = "value";
            sut.Save(true);
            sut.Save(true);

            Assert.Pass();
        }
Пример #5
0
        public void Save_NewFile_ShouldHaveNewContent()
        {
            var sut = new DummyResourceFileHandlerBase(SourceFile);

            sut["secondline"] = "value";
            sut.Save(true);

            var lines = File.ReadLines(SourceFile);

            Assert.That(lines.Count(), Is.EqualTo(2));
        }
Пример #6
0
        public void Save_OldFile_ShouldKeepContent()
        {
            var sut = new DummyResourceFileHandlerBase(SourceFile);

            sut["secondline"] = "value";
            var backup = sut.Save(true);

            var lines = File.ReadLines(backup);

            Assert.That(lines.Count(), Is.EqualTo(1));
        }
Пример #7
0
        public void Update_WithOneSource_DestinationFilled()
        {
            var source = new DummyResourceFileHandlerBase("Source.txt");

            source["key"] = "value";
            _sut.AddSource(source);
            var destination = new DummyResourceFileHandlerBase("Destination.txt");

            _sut.AddDestination(destination);

            _sut.Update();

            Assert.That(destination.Keys.Count, Is.EqualTo(source.Keys.Count));
        }
Пример #8
0
        public void Update_WithSeveralSourcesAndSameKeys_DestinationFilled()
        {
            var source = new DummyResourceFileHandlerBase("Source.txt");

            source["key"] = "value";
            _sut.AddSource(source);
            source        = new DummyResourceFileHandlerBase("Source2.txt");
            source["key"] = "value2";
            _sut.AddSource(source);
            var destination = new DummyResourceFileHandlerBase("Destination.txt");

            _sut.AddDestination(destination);

            _sut.Update();

            Assert.That(destination.Keys.Count, Is.EqualTo(1));
            Assert.That(destination["key"], Is.EqualTo("value2"));
        }
Пример #9
0
        public void Ctor_NoFile_FileCreated()
        {
            var sut = new DummyResourceFileHandlerBase(_myfileTxt);

            Assert.That(File.Exists(_myfileTxt));
        }