everyone, I'm writing a unit test for my Builder class and I have the following error. Method TestDB.BuilderTest.CustomerBuilderTest.CLassInitialize has the wrong signature. The method must be static, public does not return a value and should take a single parameter of type TestContext. Additionally, if you are using async-await in the method then return-type must be Task.
this is My unit test
[TestClass]
public class CustomerBuilderTest
{
private static CustomerDeserializer _customerDeserializer;
private static string path;
[ClassInitialize]
public static void CLassInitialize(TestContext context)
{
path = Path.Combine(Environment.CurrentDirectory, @"Folder\", "Customer.json");
}
[TestInitialize]
public static void TestInitialize()
{
_customerDeserializer = new CustomerDeserializer();
}
[TestMethod]
public void CusomerBuilder_MustReturnCustomers()
{
//Arange
//Act
var dtos = CustomerDeserializer.Deserialize(path);
var dto = dtos.FirstOrDefault(e => e.Email == "hi@gmail.com");
var customer = CustomerBuilder.CustomerBuild(dto);
//Asset
Assert.IsNotNull(dto);
Assert.AreEqual(customer.FirstName,"tina");
}
}
}
this is My Builder class
public class CustomerBuilder
{
public static Customer CustomerBuild(DtoCustomer dto)
{
return new Customer()
{
FirstName = dto.FirstName,
LastName = dto.LastName,
Address = dto.Address,
Email = dto.Email,
Code = int.Parse(dto.Code),
PhoneNumber = dto.Phone
};
}
}
I checked lots of sites but I didn't find any solution can you help me?