You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using POCO properties in foreach loop and trying to setup two mocks the NS4000 warning occur. When foreach loop is removed there are no warnings. Looks like wrong behavior.
using NSubstitute;using NUnit.Framework;using System;using System.Collections.Generic;namespaceTests{publicclassTests{[Test]publicvoidTest1(){varlist=newList<DateTime>(1){ DateTime.Now };varenumerator1= Substitute.For<IEnumerator<DateTime>>();varenumerator2= Substitute.For<IEnumerator<DateTime>>();foreach(var date in list){// case 1: use date
enumerator1.Current.Returns(date);// No warnings// case 2: use date properties//enumerator1.Current.Returns(new DateTime(date.Ticks)); // NS4000 here
enumerator2.Current.Returns(new DateTime(date.Ticks));// NS4000 here in both cases}}}}
The text was updated successfully, but these errors were encountered:
NSubstitute 4.2.0.0
NSubstitute.Analyzers.CSharp 1.0.10
When using POCO properties in
foreach
loop and trying to setup two mocks the NS4000 warning occur. Whenforeach
loop is removed there are no warnings. Looks like wrong behavior.The text was updated successfully, but these errors were encountered: