Exemplo n.º 1
0
        public void CreatePlaceShould_CallUnitOfWorkMethodACommit(string name, string type, string contact,
                                                                  string weekendHours, string weekdaayHours, string details, int?averageBill,
                                                                  string userId, string addressId)
        {
            var repositoryMock = new Mock <IRepository <Place> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IPlaceFactory>();

            var service = new Services.PlaceService(repositoryMock.Object,
                                                    unitOfWorkMock.Object, factoryMock.Object);

            var addressIdGuid = new Guid(addressId);
            var place         = new Place()
            {
                ManagerId    = userId,
                AddressId    = addressIdGuid,
                Name         = name,
                Type         = type,
                Contact      = contact,
                WeekendHours = weekendHours,
                WeekdayHours = weekdaayHours,
                Details      = details,
                AverageBill  = averageBill,
            };

            factoryMock.Setup(f => f.CreatePlace(name, type, contact, weekendHours, weekdaayHours,
                                                 details, averageBill, userId, addressIdGuid))
            .Returns(place);

            service.CreatePlace(name, type, contact, weekendHours, weekdaayHours,
                                details, averageBill, userId, addressIdGuid);

            unitOfWorkMock.Verify(f => f.Commit(), Times.Once);
        }
Exemplo n.º 2
0
        public void CreatePlaceShould_CallFactoryMethodCreatePlace(string name, string type, string contact,
                                                                   string weekendHours, string weekdaayHours, string details, int?averageBill,
                                                                   string userId, string addressId)
        {
            var repositoryMock = new Mock <IRepository <Place> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IPlaceFactory>();

            var service = new Services.PlaceService(repositoryMock.Object,
                                                    unitOfWorkMock.Object, factoryMock.Object);

            var addressIdGuid = new Guid(addressId);

            service.CreatePlace(name, type, contact, weekendHours, weekdaayHours,
                                details, averageBill, userId, addressIdGuid);

            factoryMock.Verify(f => f.CreatePlace(name, type, contact, weekendHours, weekdaayHours,
                                                  details, averageBill, userId, addressIdGuid), Times.Once);
        }