public void IsAlreadyRegistered()
        {
            //Arrange
            Mock <IEventRegRepo> mock = new Mock <IEventRegRepo>();

            mock.Setup(m => m.GetAllEvents()).Returns(new List <Event>
            {
                new Event
                {
                    Name             = "Testing Market",
                    UkStartTime      = new DateTime(2017, 5, 1, 12, 30, 0),
                    UkEndTime        = new DateTime(2017, 5, 1, 18, 0, 0),
                    RegisteredEmails = new List <string> {
                        "*****@*****.**"
                    },
                    Location = new Location
                    {
                        City    = "London",
                        Country = new Country
                        {
                            Name        = "United Kingdom",
                            CountryCode = "UK"
                        },
                        LocationTimezone = new LocationTimezone
                        {
                            Id   = "UK",
                            Name = "GMT Standard Time"
                        }
                    }
                }
            });

            RegisterReq req = new RegisterReq
            {
                EventName        = "Testing Market",
                Country          = "UK",
                ArrivalTime      = new DateTime(2017, 5, 1, 11, 0, 0),
                RegistrationDate = new DateTime(2017, 04, 30, 23, 18, 0),
                FirstName        = "Adam",
                LastName         = "Stevens",
                EmailAddress     = "*****@*****.**"
            };

            //Act
            EventRegService service = new EventRegService(mock.Object);

            service.ValidateRegister(ref req);

            //Assert
            Assert.IsTrue(req.IsError);
            Assert.IsTrue(req.Error.Length > 0);
        }
Esempio n. 2
0
        // GET: api/<controller>

        public EventRegController(EventRegService eventRegService)
        {
            _eventRegService = eventRegService;
        }