How to make the method to fall from the exception?

There is a method repository, which adds the object to the database ( in my case, the base - list ). However, if you pass it an empty object needs to fall with the exception for further processing.
public bool Save(T entity)
{
 entity = new T();

 bool SaveResult = false;

 if (entity != null)
{
AllItem.Add(entity);

 SaveResult = true;
}
 return SaveResult;
 }


And here is the test code
[TestMethod]
 public void SaveNullObjectTest()
{
 Ent AccountModel = new AccountModel();

 ent = null;

 bool result = AccountBS.Save(ent);

Assert.IsFalse(result);
 }

But the result is somehow still true
June 3rd 19 at 19:18
2 answers
June 3rd 19 at 19:20
Solution
entity = new T();

It does not bother you ?
An object instance is created, the variable will not be null
Set yourself ReSharper. He immediately messages about issues such nevnimateljnostj. - Alize_Moen commented on June 3rd 19 at 19:23
June 3rd 19 at 19:22
public void Save(T entity)
{
 if (entity == null)
 throw new ArgumentNullException(nameof(entity));

AllItem.Add(entity);
}

Find more questions by tags C#ASP.NET