public void UpdateListing()
        {
            using var _context = TestContext.GetContext();
            var _mapper = TestMapper.GetTestMapper();
            var _studioListingService = new StudioListingService(_context, _mapper);

            var update = new CreateUpdateStudioDto
            {
                Name        = "Basil's Place", // updated name
                Description = "We are the best studio",
                IsBooked    = false,
                Rate        = 20
            };

            var response = _studioListingService.UpdateListing(2, update);

            Assert.IsType <ServiceResponse <StudioListingDto> >(response);
            Assert.IsType <StudioListingDto>(response.Data);
            Assert.Equal("Basil's Place", response.Data.Name);
            Assert.Equal("We are the best studio", response.Data.Description);
            Assert.False(response.Data.IsBooked);
            Assert.Equal(20, response.Data.Rate);
            Assert.NotEqual("The Hive", response.Data.Name);
            Assert.True(response.IsSuccess);
        }
        public void ShouldGetAllClients()
        {
            using var _context = TestContext.GetContext();
            var _mapper        = TestMapper.GetTestMapper();
            var _clientService = new ClientService(_mapper, _context);

            var response = _clientService.GetAllClients();

            Assert.IsType <ServiceResponse <List <HomeBooth.Services.DTO.ApplicationUserDto> > >(response);
            Assert.True(response.IsSuccess);
            Assert.Equal(2, _context.Clients.Count());
        }
        public void ShouldDeleteClient()
        {
            using var _context = TestContext.GetContext();
            var _mapper        = TestMapper.GetTestMapper();
            var _clientService = new ClientService(_mapper, _context);

            var response = _clientService.DeleteClient("id1");

            Assert.IsType <ServiceResponse <bool> >(response);
            Assert.True(response.IsSuccess);
            Assert.Equal(1, _context.Clients.Count());
        }
Beispiel #4
0
        public void ShouldDeleteHost()
        {
            using var _context = TestContext.GetContext();
            var _mapper      = TestMapper.GetTestMapper();
            var _hostService = new HostService(_mapper, _context);

            var response = _hostService.DeleteHost("1");

            Assert.IsType <ServiceResponse <ApplicationUserDto> >(response);
            Assert.NotNull(response.Data);
            Assert.Equal("Roger", response.Data.FirstName);
        }
        public void GetAllListings()
        {
            using var _context = TestContext.GetContext();
            var _mapper = TestMapper.GetTestMapper();
            var _studioListingService = new StudioListingService(_context, _mapper);

            var response = _studioListingService.GetAllListings();

            Assert.IsType <ServiceResponse <List <StudioListingDto> > >(response);
            Assert.IsType <List <StudioListingDto> >(response.Data);
            Assert.Single(response.Data);
        }
        public void ShouldGetClientById()
        {
            using var _context = TestContext.GetContext();
            var _mapper        = TestMapper.GetTestMapper();
            var _clientService = new ClientService(_mapper, _context);

            var client = _clientService.GetClientById("id2");

            Assert.IsType <ServiceResponse <HomeBooth.Services.DTO.ApplicationUserDto> >(client);
            Assert.Equal("Fatboi", client.Data.FirstName);
            Assert.Equal("Pilsner", client.Data.LastName);
            Assert.True(client.IsSuccess);
        }
Beispiel #7
0
        public void ShouldGetAllHosts()
        {
            using var _context = TestContext.GetContext();
            var _mapper      = TestMapper.GetTestMapper();
            var _hostService = new HostService(_mapper, _context);

            var response = _hostService.GetAllHosts();

            Assert.IsType <ServiceResponse <List <ApplicationUserDto> > >(response);
            Assert.NotNull(response.Data);
            Assert.Equal(2, response.Data.Count);
            Assert.True(response.IsSuccess);
        }
        public void GetListingById()
        {
            using var _context = TestContext.GetContext();
            var _mapper = TestMapper.GetTestMapper();
            var _studioListingService = new StudioListingService(_context, _mapper);

            var response = _studioListingService.GetListingById(2);

            Assert.IsType <ServiceResponse <StudioListingDto> >(response);
            Assert.IsType <StudioListingDto>(response.Data);
            Assert.Equal(2, response.Data.Id);
            Assert.True(response.IsSuccess);
        }
        public void ShouldUpdateClient()
        {
            using var _context = TestContext.GetContext();
            var _mapper        = TestMapper.GetTestMapper();
            var _clientService = new ClientService(_mapper, _context);

            var client = _context.Clients.Find("id1");

            client.FirstName = "Rudy";
            var updateResponse = _clientService.UpdateClient(client);

            Assert.IsType <ServiceResponse <HomeBooth.Services.DTO.ApplicationUserDto> >(updateResponse);
            Assert.True(updateResponse.IsSuccess);
            Assert.Equal("Rudy", updateResponse.Data.FirstName);
            Assert.Equal("Pilsner", updateResponse.Data.LastName);
        }
Beispiel #10
0
        public void ShouldCreateHost()
        {
            using var _context = TestContext.GetContext();
            var _mapper      = TestMapper.GetTestMapper();
            var _hostService = new HostService(_mapper, _context);

            var newHost = new Host {
                Id = "3", FirstName = "Richard"
            };

            var response = _hostService.CreateHost(newHost);

            Assert.IsType <ServiceResponse <ApplicationUserDto> >(response);
            Assert.NotNull(response.Data);
            Assert.Equal("Richard", response.Data.FirstName);
        }
        public void DeleteListing()
        {
            using var _context = TestContext.GetContext();
            var _mapper = TestMapper.GetTestMapper();
            var _studioListingService = new StudioListingService(_context, _mapper);

            var response = _studioListingService.DeleteListing(2);

            Assert.IsType <ServiceResponse <StudioListingDto> >(response);
            Assert.IsType <StudioListingDto>(response.Data);
            Assert.True(response.IsSuccess);

            var studios = _context.Studios.ToList();

            Assert.Empty(studios);
        }
Beispiel #12
0
        public void ShouldUpdateHost()
        {
            using var _context = TestContext.GetContext();
            var _mapper      = TestMapper.GetTestMapper();
            var _hostService = new HostService(_mapper, _context);

            var host = _context.Hosts.Find("1");

            // Update
            host.FirstName = "Richard";
            host.LastName  = "Wright";

            var response = _hostService.UpdateHost(host);

            Assert.IsType <ServiceResponse <ApplicationUserDto> >(response);
            Assert.NotNull(response.Data);
            Assert.Equal("Richard", response.Data.FirstName);
            Assert.Equal("Wright", response.Data.LastName);
        }
        public void CreateListing()
        {
            using var _context = TestContext.GetContext();
            var _mapper = TestMapper.GetTestMapper();
            var _studioListingService = new StudioListingService(_context, _mapper);

            var newStudio = new CreateUpdateStudioDto
            {
                Name        = "Chaos Records",
                Description = "The crazy studio",
                IsBooked    = false,
                Rate        = 23
            };

            var response = _studioListingService.CreateListing(newStudio);

            Assert.IsType <ServiceResponse <StudioListingDto> >(response);
            Assert.Equal("Chaos Records", response.Data.Name);
            Assert.Equal("The crazy studio", response.Data.Description);
            Assert.True(response.IsSuccess);
        }
        public void ShouldCreateClient()
        {
            using var _context = TestContext.GetContext();
            var _mapper        = TestMapper.GetTestMapper();
            var _clientService = new ClientService(_mapper, _context);

            var newClient = new Client
            {
                CreatedOn   = DateTime.UtcNow,
                Email       = "*****@*****.**",
                FirstName   = "Rudy",
                LastName    = "Pilsner",
                PhoneNumber = "424-757-8007",
            };

            var response = _clientService.CreateClient(newClient);

            Assert.IsType <ServiceResponse <HomeBooth.Services.DTO.ApplicationUserDto> >(response);
            Assert.Equal("Rudy", response.Data.FirstName);
            Assert.Equal("Pilsner", response.Data.LastName);
            Assert.True(response.IsSuccess);
        }