public void Name_IsGet()
        {
            // Arrange
            var command = new GetCommand(VocabularyStubFactory.Stub());

            // Assert
            Assert.AreEqual(command.Name, "get");
        }
Example #2
0
        public void Name_IsAdd()
        {
            // Arrange
            var command = new AddCommand(VocabularyStubFactory.Stub());

            // Assert
            Assert.AreEqual(command.Name, "add");
        }
        public void Execute_PassNull_ThrowsArgumentNullException()
        {
            // Arrange
            var command = new GetCommand(VocabularyStubFactory.Stub());

            // Assert
            Assert.Throws <ArgumentNullException>(() => command.Execute(null));
        }
Example #4
0
        public void Name_IsDelete()
        {
            // Arrange
            var command = new DeleteCommand(VocabularyStubFactory.Stub());

            // Assert
            Assert.AreEqual(command.Name, "delete");
        }
        public void Execute_PassEmptyParameters_ReturnsWordOrMeansAreNotSet()
        {
            // Arrange
            var command = new GetCommand(VocabularyStubFactory.Stub());

            // Act
            var result = command.Execute(new string[0]);

            // Assert
            Assert.AreEqual(result, Default.WordIsNotSet);
        }
        public void Execute_PassWordAndVocabularyReturnEmptyResults_ReturnNoSuchWord()
        {
            // Arrange
            var word    = "aaa";
            var command = new GetCommand(VocabularyStubFactory.Get(word, new string[0]));

            // Act
            var result = command.Execute(new [] { word });

            // Assert
            Assert.AreEqual(result, Default.NoSuchWord);
        }
Example #7
0
        public void Execute_PassOnlyWordWithoutMeans_ReturnsMeansAreNotSet()
        {
            // Arrange
            var word    = "aaa";
            var command = new AddCommand(VocabularyStubFactory.Stub());

            // Act
            var result = command.Execute(new[] { word });

            // Assert
            Assert.AreEqual(result, Default.MeansAreNotSet);
        }
        public void Execute_PassWordAndVocabularyReturnsMeans_ReturnMeansLineByLine()
        {
            // Arrange
            var word    = "aaa";
            var means   = new [] { "bbb", "ccc" };
            var command = new GetCommand(VocabularyStubFactory.Get(word, means));

            // Act
            var result = command.Execute(new[] { word });

            // Assert
            Assert.AreEqual(result, $"{means[0]}\r\n{means[1]}\r\n");
        }
Example #9
0
        public void Execute_PassMeansAndVocabularyReturnsEmptyResults_ReturnsMeansAreAlreadyAdded()
        {
            // Arrange
            var word    = "aaa";
            var means   = new [] { "bbb", "ccc" };
            var command = new AddCommand(VocabularyStubFactory.Add(word, means, new string[0]));

            // Act
            var result = command.Execute(new [] { word }.Concat(means));

            // Assert
            Assert.AreEqual(result, Default.MeansAreAlreadyAdded);
        }
Example #10
0
        public void Execute_PassWordWithMeansAndVocabularyReturnsFalse_ReturnNoSuchWordOrMean()
        {
            // Arrange
            var word    = "aaa";
            var means   = new[] { "bbb" };
            var command = new DeleteCommand(VocabularyStubFactory.Delete(word, means, false));

            // Act
            var result = command.Execute(new[] { word }.Concat(means));

            // Assert
            Assert.AreEqual(result, Default.NoSuchWordOrMean);
        }
Example #11
0
        public void Execute_PassMeansAndVocabularyReturnAddedMeans_ReturnMeansAddedFormattedMessage()
        {
            // Arrange
            var word       = "aaa";
            var means      = new[] { "bbb", "ccc" };
            var addedMeans = new[] { "ddd", "eee" };
            var command    = new AddCommand(VocabularyStubFactory.Add(word, means, addedMeans));

            // Act
            var result = command.Execute(new[] { word }.Concat(means));

            // Assert
            Assert.AreEqual(result, string.Format(Default.MeansAdded, $"{addedMeans[0]}, {addedMeans[1]}"));
        }