Giter Site home page Giter Site logo

Theories Using Object Parameters Are Displayed As Single Test Cases in GUI and Do Not Provide Case in Results File about devices.xunit HOT 6 CLOSED

xunit avatar xunit commented on August 16, 2024 1
Theories Using Object Parameters Are Displayed As Single Test Cases in GUI and Do Not Provide Case in Results File

from devices.xunit.

Comments (6)

clairernovotny avatar clairernovotny commented on August 16, 2024

/cc @bradwilson can we just ToString() other types used in this context for the display names?

from devices.xunit.

bradwilson avatar bradwilson commented on August 16, 2024

This is not about display names; this is about the fact that the theory data is not serializable.

from devices.xunit.

clairernovotny avatar clairernovotny commented on August 16, 2024

If the custom types implemented IXunitSerializable, would it work better?

from devices.xunit.

bradwilson avatar bradwilson commented on August 16, 2024

Yes.

from devices.xunit.

Jyosua avatar Jyosua commented on August 16, 2024

I wrote a wrapper object that implements the IXunitSerializable interface and that corrected this issue for me. Sorry for the bother. I partially modified code I saw Brad posted here: xunit/xunit#429

    public class MemberDataObject : IXunitSerializable
    {
        public MemberDataObject() { }  // Needed for deserializer

        public MemberDataObject(object pTestObject)
        {
            TestObject = pTestObject;
            TestObjectName = TestObject.GetType().Name;
        }

        public object TestObject { get; private set; }
        public string TestObjectName { get; private set; }

        public void Deserialize(IXunitSerializationInfo serializationInfo)
        {
            TestObject = serializationInfo.GetValue<string>("TestObjectName");
        }

        public void Serialize(IXunitSerializationInfo serializationInfo)
        {
            serializationInfo.AddValue("TestObjectName", TestObjectName);
        }

        public override string ToString()
        {
            return TestObjectName + "()";
        }

        public T GetObject<T>()
        {
            if (TestObject is T)
                return (T)TestObject;
            else
                return default (T);
        }
    }

Edit: Copied the wrong implementation; that one had errors. This one works.

from devices.xunit.

clairernovotny avatar clairernovotny commented on August 16, 2024

Thanks, closing this out then.

from devices.xunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.