Skip to main content
added 190 characters in body
Source Link

If controller.Create() is always creating ViewResult you must use explicit cast

var viewResult = (ViewResult)controller.Create();

else you must write another test for controller.Create().

The assertion code var viewModel = viewResult.Model as DraftViewModel; are using as, if the conversion isn't possible, as returns null so instead of IsInstanceOfType use IsNUllIsNotNUll.

By the way, I can't get the act of your test by seeing your method name and I recommend you to read this article.

If controller.Create() is always creating ViewResult you must use explicit cast

var viewResult = (ViewResult)controller.Create();

else you must write another test for controller.Create().

The assertion code var viewModel = viewResult.Model as DraftViewModel; are using as, if the conversion isn't possible, as returns null so instead of IsInstanceOfType use IsNUll.

By the way, I can't get the act of your test by seeing your method name and I recommend you to read this article.

If controller.Create() is always creating ViewResult you must use explicit cast

var viewResult = (ViewResult)controller.Create();

else you must write another test for controller.Create().

The assertion code var viewModel = viewResult.Model as DraftViewModel; are using as, if the conversion isn't possible, as returns null so instead of IsInstanceOfType use IsNotNUll.

By the way, I can't get the act of your test by seeing your method name and I recommend you to read this article.

added 190 characters in body
Source Link

If controller.Create() is always creating ViewResult any time so you must use explicit cast

var viewResult = (ViewResult)controller.Create();

else you must write another test for controller.Create().

The assertion code var viewModel = viewResult.Model as DraftViewModel; are using as, if the conversion isn't possible, as returns null so instead of IsInstanceOfType use IsNUll.

By the way, I can't get the act of your test by seeing your method name and I recommend you to read this article.

If controller.Create() is creating ViewResult any time so you must use explicit cast

var viewResult = (ViewResult)controller.Create();

else you must write another test for controller.Create().

By the way, I can't get the act of your test by seeing your method name and I recommend you to read this article.

If controller.Create() is always creating ViewResult you must use explicit cast

var viewResult = (ViewResult)controller.Create();

else you must write another test for controller.Create().

The assertion code var viewModel = viewResult.Model as DraftViewModel; are using as, if the conversion isn't possible, as returns null so instead of IsInstanceOfType use IsNUll.

By the way, I can't get the act of your test by seeing your method name and I recommend you to read this article.

Source Link

If controller.Create() is creating ViewResult any time so you must use explicit cast

var viewResult = (ViewResult)controller.Create();

else you must write another test for controller.Create().

By the way, I can't get the act of your test by seeing your method name and I recommend you to read this article.