Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- namespace tacGenericTest
- {
- [TestClass]
- public class GenericTest
- {
- [TestMethod]
- public void Test()
- {
- Assert.AreEqual("Person", new Person().Save());
- Assert.AreEqual("Apartment", new Apartment().Save());
- }
- }
- class MongoEmu
- {
- public string Save<T>(T data)
- {
- return typeof(T).Name;
- }
- }
- public class Repository
- {
- public string Save<T>(T data)
- {
- return new MongoEmu().Save(data);
- }
- }
- public class EntityBase<T>
- where T : EntityBase<T>
- {
- public string Save()
- {
- return new Repository().Save((T) this);
- }
- }
- public class Person : EntityBase<Person>
- {
- }
- public class Apartment : EntityBase<Apartment>
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement