PetProject
----------------------------------------------------------------------------------------------------
public enum CardValue { Two = 2, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace }
public enum CardSuit { Spades, Diamonds, Clubs, Hearts }
----------------------------------------------------------------------------------------------------
public class Card
{
public Card(CardValue value, CardSuit suit)
{
Value = value;
Suit = suit;
}
public CardValue Value { get; }
public CardSuit Suit { get; }
public override string ToString() => $"{Value} of {Suit}";
}
----------------------------------------------------------------------------------------------------
using Xunit;
namespace PetProject1.UnitTest
{
public class CardTests
{
[Fact]
public void CanCreateCardWithValue()
{
var card = new Card(CardValue.Ace, CardSuit.Spades);
Assert.Equal(CardSuit.Spades, card.Suit);
Assert.Equal(CardValue.Ace, card.Value);
}
[Fact]
public void CanCreateDescribeCard()
{
var card = new Card(CardValue.Ace, CardSuit.Spades);
Assert.Equal("Ace of Spades", card.ToString());
}
}
}
PetProject.UnitTest
Install-Package xUnit
Install-Package xUnit.Runner.VisualStudio
Install-Package FluentAssertions
Unit Test Explorer
Test > Windows > Test Explorer
ReSharper > Unit Tests > Unit Tests