Exemplo n.º 1
0
        public void AddLine_ThrowsException_IfLineIsReference()
        {
            var storage = new ConsoleStorage(_connection.Object);

            Assert.Throws <ArgumentException>("line", () => storage.AddLine(_consoleId, new ConsoleLine()
            {
                IsReference = true
            }));
        }
Exemplo n.º 2
0
        public void AddLine_ShortLineIsAddedToSet()
        {
            var storage = new ConsoleStorage(_connection.Object);
            var line    = new ConsoleLine()
            {
                Message = "test"
            };

            storage.AddLine(_consoleId, line);

            Assert.False(line.IsReference);
            _transaction.Verify(x => x.AddToSet($"console:{_consoleId}", It.IsAny <string>()));
            _transaction.Verify(x => x.SetRangeInHash($"console:refs:{_consoleId}", It.IsAny <IEnumerable <KeyValuePair <string, string> > >()), Times.Never);
        }
Exemplo n.º 3
0
        public void AddLine_ShortLineIsAddedToSet()
        {
            var storage = new ConsoleStorage(_connection.Object);
            var line    = new ConsoleLine()
            {
                Message = "test"
            };

            storage.AddLine(_consoleId, line);

            Assert.False(line.IsReference);
            _connection.Verify(x => x.CreateWriteTransaction(), Times.Once);
            _transaction.Verify(x => x.AddToSet(_consoleId.GetSetKey(), It.IsAny <string>(), It.IsAny <double>()));
            _transaction.Verify(x => x.SetRangeInHash(_consoleId.GetHashKey(), It.IsAny <IEnumerable <KVP> >()), Times.Never);
            _transaction.Verify(x => x.Commit(), Times.Once);
        }
Exemplo n.º 4
0
        public void AddLine_ProgressBarIsAddedToSet_AndProgressIsUpdated()
        {
            var storage = new ConsoleStorage(_connection.Object);
            var line    = new ConsoleLine()
            {
                Message       = "1",
                ProgressValue = 10
            };

            storage.AddLine(_consoleId, line);

            Assert.False(line.IsReference);
            _connection.Verify(x => x.CreateWriteTransaction(), Times.Once);
            _transaction.Verify(x => x.AddToSet(_consoleId.GetSetKey(), It.IsAny <string>(), It.IsAny <double>()));
            _transaction.Verify(x => x.SetRangeInHash(_consoleId.GetHashKey(), It2.AnyIs <KVP>(p => p.Key == "progress")));
            _transaction.Verify(x => x.Commit(), Times.Once);
        }
Exemplo n.º 5
0
        public void AddLine_LongLineIsAddedToHash_AndReferenceIsAddedToSet()
        {
            var storage = new ConsoleStorage(_connection.Object);
            var line    = new ConsoleLine()
            {
                Message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " +
                          "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud " +
                          "exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " +
                          "dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. " +
                          "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
            };

            storage.AddLine(_consoleId, line);

            Assert.True(line.IsReference);
            _transaction.Verify(x => x.AddToSet($"console:{_consoleId}", It.IsAny <string>()));
            _transaction.Verify(x => x.SetRangeInHash($"console:refs:{_consoleId}", It.IsAny <IEnumerable <KeyValuePair <string, string> > >()));
        }
Exemplo n.º 6
0
        public void AddLine_ThrowsException_IfLineIsNull()
        {
            var storage = new ConsoleStorage(_connection.Object);

            Assert.Throws <ArgumentNullException>("line", () => storage.AddLine(_consoleId, null));
        }
Exemplo n.º 7
0
        public void AddLine_ThrowsException_IfConsoleIdIsNull()
        {
            var storage = new ConsoleStorage(_connection.Object);

            Assert.Throws <ArgumentNullException>("consoleId", () => storage.AddLine(null, new ConsoleLine()));
        }