3

I have unit test for a ServiceStack based service that passes on my windows workstation, however the TeamCity server which is on ubuntu/mono doesn't pass - other tests do run however, just one in particular.

This fails

    [Test]
    public void Post_Valid_Property_Should_Return_HttpStatus_OK()
    {
        var manager = new Mock<IRedisClientsManager>();
        var redisClient = new Mock<IRedisClient>();
        var redisTypedClient = new Mock<IRedisTypedClient<Share.Property.Model.Property>>();
        manager.Setup(t => t.GetClient()).Returns(redisClient.Object);
        redisClient.Setup(t => t.As<Share.Property.Model.Property>()).Returns(redisTypedClient.Object);
        var sut = new SomeService(manager.Object);
        var result = sut.Post(new PropertySaveRequest {Property = new Share.Property.Model.Property { Id = 1, OwnerId = 2 } });
        Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK));

    }

Other tests not using mocks pass fine eg.

    [Test]
    public void Post_Invalid_Property_Should_Throw_Exception()
    {
        _container = new WindsorContainer()
            .Install(new PropertyInstaller());
        var service = _container.Resolve<IPropertyService>();
        Assert.That(() => service.Post(new PropertySaveRequest { Property = new Share.Property.Model.Property{Id=-11, OwnerId = -14} }),
            Throws.Exception.TypeOf<ArgumentOutOfRangeException>());

    }

TeamCity log

My guess is the error is Moq related, as the other test can use Castle IOC without throwing.

Test(s) failed. System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary.

Any ideas appreciated

MikeW
  • 4,749
  • 9
  • 42
  • 83
  • http://stackoverflow.com/questions/18034341/system-collections-generic-keynotfoundexception-with-mono-but-not-microsofts Not surprising at all, as not every tool works for Mono. – Lex Li Jan 24 '15 at 07:50
  • Rhino Mocks same error - know of any mocking libs that work on mono? – MikeW Jan 24 '15 at 09:22
  • Then you can find https://www.google.com/search?q=Mocking+framework+mono&sourceid=ie7&rls=com.microsoft:en-US:IE-Address&ie=&oe=&gws_rd=ssl – Lex Li Jan 24 '15 at 11:23
  • What a strange response... – MikeW Jan 24 '15 at 14:27

0 Answers0