byte enum as parameter not matching argument

2 posts, 0 answers
  1. Russell
    Russell avatar
    76 posts
    Member since:
    Sep 2006

    Posted 28 Nov 2012 Link to this post

    I have an enum declared as

    public enum SubdivisionTypeCode : byte
        {
            None = 255,
            State = 0,
            County = 1,
            City = 2,
            Village = 3,
            Township = 4,
            CitySchoolDistrict = 5,
            SchoolDistrict = 6,
            JtVocSchoolDistrict = 7,
            Miscellaneous = 8,
            University = 9,
            PooledFinancing = 10
        }

    when I try to use that in a parameter in a Mocking Arrange, it doesn't match and the mock doesn't get called correctly.
    public interface ISubdivisionTypeRepository
    {
        ISubdivisionType Get(SubdivisionTypeCode subdivisionTypeCode);
    }
     
    ...
    [Test]
    var subdivisionTypeCode = SubdivisionTypeCode.City;
    var subdivisionType = new SubdivisionType(subdivisionTypeCode: SubdivisionTypeCode.City);
    
    var subdivisionTypeRepository = Mock.Create<ISubdivisionTypeRepository>();
    Mock.Arrange(() => subdivisionTypeRepository.Get(subdivisionTypeCode)).Returns(subdivisionType);
     
    var s = subdivisionTypeRepository.Get(subdivisionTypeCode);
    In this case s returns null.  

    If I remove the type from the enum (or change it to int) the above code returns the correct instance as expected.

    Thanks,
    Eric
  2. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 30 Nov 2012 Link to this post

    Hi Eric,

    I sent you a reply at Ticket # 635484. Please check it out.  Hopefully it will be enough to resolve your issue.

    Kind Regards
    Mehfuz
    the Telerik team
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
  3. DevCraft R3 2016 release webinar banner
Back to Top