As an assessment, I received the following Testcase so I can implement the code behind:
[TestCase]
public void ProgrammerTest() 
{
    var address = new Address("56 Main St", "Mesa", "AZ", "38574");
    var customer = new Customer("John", "Doe", address);
    var company = new Company("Google", address);
 
    Assert.IsNullOrEmpty(customer.Id);
    customer.Save();
    Assert.IsNotNullOrEmpty(customer.Id);
 
    Assert.IsNullOrEmpty(company.Id);
    company.Save();
    Assert.IsNotNullOrEmpty(company.Id);
 
    Customer savedCustomer = Customer.Find(customer.Id);
    Assert.IsNotNull(savedCustomer);
    Assert.AreSame(customer.Address, address);
    Assert.AreEqual(savedCustomer.Address, address);
    Assert.AreEqual(customer.Id, savedCustomer.Id);
    Assert.AreEqual(customer.FirstName, savedCustomer.FirstName);
    Assert.AreEqual(customer.LastName, savedCustomer.LastName);
    Assert.AreEqual(customer, savedCustomer);
    Assert.AreNotSame(customer, savedCustomer);
 
    Company savedCompany = Company.Find(company.Id);
    Assert.IsNotNull(savedCompany);
    Assert.AreSame(company.Address, address);
    Assert.AreEqual(savedCompany.Address, address);
    Assert.AreEqual(company.Id, savedCompany.Id);
    Assert.AreEqual(company.Name, savedCompany.Name);
    Assert.AreEqual(company, savedCompany);
    Assert.AreNotSame(company, savedCompany);
 
    customer.Delete();
    Assert.IsNullOrEmpty(customer.Id);
    Assert.IsNull(Customer.Find(customer.Id));
 
    company.Delete();
    Assert.IsNullOrEmpty(company.Id);
    Assert.IsNull(Company.Find(company.Id));
}
The requirements are:
- In C# create a single class that when subclassed allows this sample test code to run using only the file system for storage, no pre-built database allowed; use files.
- Create all classes required to compile and pass the test case; you may not modify the test. The test is not wrong, it's not a trick.
- The Id,Save,Delete, andFindmethods must be in the super class only; subclasses must not implement these methods themselves.
Here are a class example I could extract from the test cases:
public abstract class MyBase
{
    public abstract void Save();
    public abstract void Delete();
}
public class Company : MyBase
{
    public string Id { get; set; }
    public string Name { get; set; }
    public Address Address { get; set; }
    public Company(string name, Address address)
    {
        this.Name = name;
        this.Address = address;
    }
    internal static Company Find(string id)
    {
        throw new NotImplementedException();
    }
    public override void Delete()
    {
       throw new NotImplementedException();
    }
    public override void Save()
    {
        object company = new List<Company>();
        if (company != null)
        {
            // serialize JSON to a string and then write string to a file
            File.WriteAllText(@"c:\company.json", JsonConvert.SerializeObject(company));
        }
    }
}
I have experience creating TestCases for a given code, but not the other way out and I could extract the Classes from it but, how can I implement the methods Save(), Delete(), Find(customer.Id) as Generic Types without passing the populated data classes? I know I could do something like void Save(object obj) and implement the passed object on the Base, but the testcase just calls like customer.Save()... So, how can I do this?
Thanks in advance for any input!
 
     
    