Exemplo n.º 1
0
        public void GivenADispeceratWhenCallAddPersonWithANameThatAlreadyExistsThenAExceptionIsThrown()
        {
            //arange
            var sursaDeDateMock = new Mock<ISursaDeDate>();
            var personInitMock = new Mock<IPersonInitialization>();

            DispecerA A = new DispecerA(sursaDeDateMock.Object, personInitMock.Object);

            //setare pe mock
            personInitMock.Setup(s => s.CreatePerson()).Returns(new Persoana()
            {
                Nume = "Anonim",
                Prenume = "PrenumeMock",
                Varsta = 22
            });

            //act
            A.Add();
        }
Exemplo n.º 2
0
        public void GivenADispeceratWhenCallAddPersonAndPersonHasVarstaLessThan18ThenAnExceptionIsThrown()
        {
            //arange
            var sursaDeDateMock = new Mock<ISursaDeDate>();
            var personInitMock = new Mock<IPersonInitialization>();

            //setare pe mock
            personInitMock.Setup(s => s.CreatePerson()).Returns(new Persoana()
            {
                Nume = "NumeMock",
                Prenume = "PrenumeMock",
                Varsta = 17
            });

            DispecerA A = new DispecerA(sursaDeDateMock.Object, personInitMock.Object);

            //act
            A.Add();
        }
Exemplo n.º 3
0
        public void GivenADispeceratWhenCallAddPersonThenTheMethodAddFromISursaDeDateIsCalled()
        {
            //arange
            var sursaDeDateMock = new Mock<ISursaDeDate>();
            var personInitMock = new Mock<IPersonInitialization>();

            DispecerA A = new DispecerA(sursaDeDateMock.Object, personInitMock.Object);

            //setare pe mock
            personInitMock.Setup(s => s.CreatePerson()).Returns(new Persoana()
            {
                Nume = "NumeMock",
                Prenume = "PrenumeMock",
                Varsta = 22
            });

            //act
            A.Add();
            A.Add();

            //assert
            sursaDeDateMock.Verify(v => v.Add(It.IsAny<Persoana>()), Times.Exactly(2));
            personInitMock.Verify(v => v.CreatePerson(), Times.Exactly(2));
        }
Exemplo n.º 4
0
        public void GivenADispeceratWhenReadbyNumeThenTheMethodReadByNameFromISursaDeDateIsCalled()
        {
            //arange
            var sursaDeDateMock = new Mock<ISursaDeDate>();
            var personInitMock = new Mock<IPersonInitialization>();

            DispecerA A = new DispecerA(sursaDeDateMock.Object, personInitMock.Object);

            //setare pe mock
            personInitMock.Setup(s => s.CreatePerson()).Returns(new Persoana()
            {
                Nume = "NumeMock",
                Prenume = "PrenumeMock",
                Varsta = 22
            });

               //act
            A.ReadByNume("NumeMock");
             //assert

            sursaDeDateMock.Verify(v => v.ReadByName("NumeMock"), Times.Exactly(1));
        }