public void TypeDiscriminatorAttribute() { var fac = new TypeDiscriminatorFactory(); fac.Register(typeof(BaseDao)); fac.Register(typeof(LocationDao)); fac.Register(typeof(CityDao)); fac.Register(typeof(CountryDao)); var dao = fac.FromType <CityDao>(); fac.ClearAllRegisters(); fac.Register(typeof(BaseDto)); fac.Register(typeof(LocationDto)); fac.Register(typeof(CityDto)); fac.Register(typeof(CountryDto)); var dto = fac.FromType <CityDto>(); Assert.True(dao.Id == dto.Id, $"Type discriminators DAO & DTO must have same Id. Values are '{dao.Id}' and '{dto.Id}'"); fac.ClearAllRegisters(); fac.Register(typeof(BaseDvo <>)); fac.Register(typeof(LocationDvo <>)); //fac.Register(typeof(LocationDvo<CityDvo>)); fac.Register(typeof(CityDvo)); fac.Register(typeof(CountryDvo)); var dvo = fac.FromId(TypeDiscriminatorIds.City); var dvo2 = fac.FromId(TypeDiscriminatorIds.Location); var dvo3 = fac.FromType(typeof(LocationDvo <>)); //var dvo3 = fac.FromType(typeof(LocationDvo<CityDvo>)); Assert.True(dao.Id == dvo.Id, $"Type discriminators DAO & DVO must have same Id. Values are '{dao.Id}' and '{dvo.Id}'"); Assert.True(dvo2.Id == dvo3.Id, $"Type discriminators DAO & DVO must have same Id. Values are '{dvo2.Id}' and '{dvo3.Id}'"); Assert.True(dvo2.Inclusions.Contains(dvo), $"Type discriminator 'Location' must include 'City'"); }