Tuesday, June 15, 2021

Creating some Unit tests with xUnit, FakeitEasy and FluentAssertions

 











As you can see here a very basic sample of a unit test created for a notification service on a ASP.net MVC 5 solution.

Here the code to test a failing list of emails.

[Fact]
            public void ListeCourrielsEstValide_ListeInvalide_RetourneErreur()
            {
                //Arrange
                IEnumerable<string> listeCourriels = new string[] { "123%xer;456#wer;yuio!879" }; 
                bool valeurAttendu = false;

                //Act
                var resultat = notificationService.ListeCourrielsEstValide(listeCourriels);

                //Assert
                resultat.Should().Be(valeurAttendu);
            }