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

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

        JustMock.Arrange(() => thing.DoSomething());
        thing.DoSomething();
        JustMock.Assert(thing);
    }
Ejemplo n.º 3
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.º 4
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.º 5
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);
        }