public override int JustMockLite()
    {
        JustMock.Reset();
        var thing = JustMock.Create <IThing>();

        return(thing.Zero());
    }
    public override void JustMockLite()
    {
        JustMock.Reset();
        var thing = JustMock.Create <IThing>();

        thing.DoNothing();
    }
Ejemplo n.º 3
0
        public MetadataBuilderTests()
        {
            const Behavior behavior = Behavior.Strict;

            var fixture = new Fixture();
            var key     = fixture.Create <string>();
            var value   = fixture.Create <string>();

            _localServerName                 = Environment.MachineName.ToLower();
            _ipAddressByServerName           = Mock.Create <IReadOnlyDictionary <string, string> >(behavior);
            _ipAddressByServerNameEnumerator = Mock.Create <IEnumerator <KeyValuePair <string, string> > >(behavior);
            _keyValuePair      = new KeyValuePair <string, string>(key, value);
            _ipAddress         = _keyValuePair.Value;
            _remoteServerNames = new List <string> {
                _keyValuePair.Key
            };
            _ping                  = Mock.Create <Ping>(behavior);
            _pingReply             = Mock.Create <PingReply>(behavior);
            _buffer                = new byte[0];
            _pingOptions           = new PingOptions(ttl: 64, dontFragment: true);
            _timeout               = 1;
            _configurationMetadata = Mock.Create <IConfigurationMetadata>(behavior);
            _pingCreator           = Mock.Create <IPingCreator>(behavior);
            _pingReplyEvaluator    = Mock.Create <IPingReplyEvaluator>(behavior);
            _testObject            = new MetadataBuilder(_configurationMetadata, _pingCreator, _pingReplyEvaluator);
        }
    public override void JustMockLite()
    {
        JustMock.Reset();
        var thing = JustMock.Create <IThing>();

        thing.OneParameter(0);
    }
Ejemplo n.º 5
0
    public override int JustMockLite()
    {
        JustMock.Reset();
        var thing = JustMock.Create <IThing>();

        JustMock.Arrange(() => thing.One()).Returns(1);
        return(thing.One());
    }
Ejemplo n.º 6
0
    public override void JustMockLite()
    {
        JustMock.Reset();
        var thing = JustMock.Create <IThing>();

        JustMock.Arrange(() => thing.DoSomething());
        thing.DoSomething();
        JustMock.Assert(thing);
    }
Ejemplo n.º 7
0
    public override bool JustMockLite()
    {
        JustMock.Reset();
        var called = false;
        var thing  = JustMock.Create <IThing>();

        JustMock.Arrange(() => thing.DoSomething()).DoInstead(() => called = true);
        thing.DoSomething();
        return(called);
    }
Ejemplo n.º 8
0
        public void NetworkInformationException()
        {
            Mock.Arrange(() => _ipAddressByServerName.GetEnumerator()).Returns(_ipAddressByServerNameEnumerator);
            Mock.Arrange(() => _ipAddressByServerNameEnumerator.MoveNext()).Returns(true);
            Mock.Arrange(() => _ipAddressByServerNameEnumerator.Current).Returns(_keyValuePair);
            Mock.Arrange(() => _configurationMetadata.GetIpAddressByServerName()).Returns(_ipAddressByServerName);
            Mock.Arrange(() => _pingCreator.CreatePing()).Returns(_ping);
            Mock.Arrange(() => _ping.Send(_ipAddress, _timeout, _buffer, Arg.Matches <PingOptions>(pingOptions => pingOptions.Ttl == _pingOptions.Ttl && pingOptions.DontFragment == _pingOptions.DontFragment))).When(() => true).DoInstead(() =>
            {
                Mock.Arrange(() => ((IDisposable)_ping).Dispose());
                Mock.Arrange(() => _ipAddressByServerNameEnumerator.MoveNext()).Returns(false);
                Mock.Arrange(() => _ipAddressByServerNameEnumerator.Dispose());
            })
            .Throws <NetworkInformationException>();

            var result = _testObject.BuildEnvironmentMetadata();

            Assert.Equal(_localServerName, result.LocalServerName);
            Assert.Empty(result.RemoteServerNames);
        }
Ejemplo n.º 9
0
        public void CreateMetadata()
        {
            const Behavior mockBehavior = Behavior.Strict;

            var metadataBuilder     = Mock.Create <IMetadataBuilder>(mockBehavior);
            var testObject          = new MetadataRepository(metadataBuilder);
            var environmentMetadata = Mock.Create <IEnvironmentMetadata>(mockBehavior);
            var hierarchyMetadata   = Mock.Create <IHierarchyMetadata>(mockBehavior);
            var graphMetadata       = Mock.Create <IGraphMetadata>(mockBehavior);
            var metadata            = new Model.Metadata(environmentMetadata, hierarchyMetadata, graphMetadata);

            Mock.Arrange(() => metadataBuilder.BuildEnvironmentMetadata()).Returns(environmentMetadata);
            Mock.Arrange(() => metadataBuilder.BuildHierarchyMetadata(environmentMetadata)).Returns(hierarchyMetadata);
            Mock.Arrange(() => metadataBuilder.BuildGraphMetadata(hierarchyMetadata)).Returns(graphMetadata);

            var result = testObject.CreateMetadata();

            Assert.Same(metadata.EnvironmentMetadata, result.EnvironmentMetadata);
            Assert.Same(metadata.HierarchyMetadata, result.HierarchyMetadata);
            Assert.Same(metadata.GraphMetadata, result.GraphMetadata);
        }
Ejemplo n.º 10
0
 public override IThing JustMockLite()
 {
     JustMock.Reset();
     return(JustMock.Create <IThing>());
 }