Exemplo n.º 1
0
        public void DoesTournamentCreateIfNoTournamentInProgress()
        {
            //Arrange

            var NewTournament = new Tournament()
            {
                ID = 0, InProgress = false, Name = "test"
            };
            var ProvResult = new ProviderResult <Tournament>()
            {
                Status = ProviderStatusCode.Ok, Value = NewTournament
            };

            var Provider = new Mock <ITournamentProvider>();

            Provider.Setup(x => x.GetTournamentInProgress())
            .Returns(new ProviderResult <Tournament>()
            {
                Status = ProviderStatusCode.NotFound
            });
            Provider.Setup(x => x.Create(It.IsAny <Tournament>()))
            .Returns(ProvResult);

            ITournamentService TournamentServ = new TournamentService(Provider.Object);

            //Act
            var result = TournamentServ.CreateNewTournament(NewTournament);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(true, result.InProgress);
        }
Exemplo n.º 2
0
        public void DoesTournamentFailToCreateIfTournamentInProgress()
        {
            //Arrange
            var rtnObj = new Tournament()
            {
                InProgress = true
            };
            var returnResult = new ProviderResult <Tournament>()
            {
                Status = ProviderStatusCode.Ok, Value = rtnObj
            };
            var NewTournament = new Tournament()
            {
                ID = 0, InProgress = false, Name = "test"
            };
            var ProvResult = new ProviderResult <Tournament>()
            {
                Status = ProviderStatusCode.Ok, Value = NewTournament
            };

            var Provider = new Mock <ITournamentProvider>();

            Provider.Setup(x => x.GetTournamentInProgress())
            .Returns(returnResult);
            Provider.Setup(x => x.Create(It.IsAny <Tournament>()))
            .Returns(ProvResult);

            ITournamentService TournamentServ = new TournamentService(Provider.Object);

            //Act
            var result = TournamentServ.CreateNewTournament(NewTournament);

            //Assert
            Assert.IsNull(result);
        }