Пример #1
0
        public void TryAdd_Should_ReturnTrue()
        {
            var source    = _fixture.Create <string>();
            var converted = _fixture.Create <object>();

            _jsonConvertible.TryConvert(source, out Arg.Any <object>())
            .Returns(x =>
            {
                x[1] = converted;
                return(true);
            });

            _schemaValidation.IsValid(converted)
            .Returns(true);

            var convertible = _fixture.Create <Dictionary <string, object> >();

            _convertible.Convert(converted)
            .Returns(convertible);

            var info = Substitute.For <ThingActionInformation>();

            _factory.Convert(convertible)
            .Returns(info);

            _collection.TryAdd(source, out _).Should().BeTrue();

            _jsonConvertible
            .Received(1)
            .TryConvert(source, out Arg.Any <object>());

            _schemaValidation
            .Received(1)
            .IsValid(converted);

            _convertible
            .Received(1)
            .Convert(converted);

            _factory
            .Received(1)
            .Convert(convertible);

            _collection.Should().NotBeEmpty();
            _collection.Should().HaveCount(1);

            foreach (var item in _collection)
            {
                item.Should().Be(info);
            }
        }