Beispiel #1
0
        public void AggregateData_WithMultipleHandler_And_DuplicatedKeys()
        {
            // Arrange
            var simpleData1 = new Dictionary <string, string>()
            {
                { "Key1", "Value1" }
            };

            var infoHandler1 = new Mock <IInfoProvider>();

            infoHandler1.Setup(x => x.GetData())
            .Returns(simpleData1);

            var infoHandler2 = new Mock <IInfoProvider>();

            infoHandler2.Setup(x => x.GetData())
            .Returns(simpleData1);

            var collector = new InfoCollector(new List <IInfoProvider>()
            {
                infoHandler1.Object, infoHandler2.Object
            }, _mockLogger.Object);

            // Act
            var result = collector.AggregateData();

            // Assert
            //Assert.Throws<ArgumentException>(collector.AggregateData);
            _mockLogger.VerifyLogging(string.Format(Messages.DUPLICATED_KEY, simpleData1.First().Key), LogLevel.Warning, Times.Once());
            Assert.Equal(result, simpleData1);
        }
Beispiel #2
0
        public void ReturnEmptyData_WhenNoHandler()
        {
            // Arrange
            var collector = new InfoCollector(new List <IInfoProvider>(), _mockLogger.Object);

            // Act
            var result = collector.AggregateData();

            // Assert
            Assert.True(result.Count == 0);
        }
Beispiel #3
0
        public void AggregateData_WithMultipleHandler()
        {
            // Arrange
            var simpleData1 = new Dictionary <string, string>()
            {
                { "Key1", "Value1" }
            };

            var infoHandler1 = new Mock <IInfoProvider>();

            infoHandler1.Setup(x => x.GetData())
            .Returns(simpleData1);

            var simpleData2 = new Dictionary <string, string>()
            {
                { "Key2", "Value2" }
            };

            var infoHandler2 = new Mock <IInfoProvider>();

            infoHandler2.Setup(x => x.GetData())
            .Returns(simpleData2);

            var collector = new InfoCollector(new List <IInfoProvider>()
            {
                infoHandler1.Object, infoHandler2.Object
            }, _mockLogger.Object);

            // Act
            var result = collector.AggregateData();

            // Assert
            var dict = simpleData1.Union(simpleData2).ToDictionary(k => k.Key, v => v.Value);

            Assert.Equal(result, dict);
        }
Beispiel #4
0
        public void InstantiateHandler_ReturnDataInHandler()
        {
            // Arrange
            var simpleData = new Dictionary <string, string>()
            {
                { "Key1", "Value1" }
            };

            var infoHandlerSimple = new Mock <IInfoProvider>();

            infoHandlerSimple.Setup(x => x.GetData())
            .Returns(simpleData);

            var collector = new InfoCollector(new List <IInfoProvider>()
            {
                infoHandlerSimple.Object
            }, _mockLogger.Object);

            // Act
            var result = collector.AggregateData();

            // Assert
            Assert.Equal(result, simpleData);
        }