public void GetCustomers() { IActionResult customers = controller.Get(); OkObjectResult actionresult = customers as OkObjectResult; Assert.Equal(200, actionresult.StatusCode); }
public async Task Get_WhenCalled_ReturnsOkResult() { // Act var okResult = await _controller.Get(); // Assert Assert.IsType <OkObjectResult>(okResult); }
public void Getall_WhenCalled_ReturnsOkResult() { // Act var okResult = customerController.Get(); // Assert Assert.IsType <OkObjectResult>(okResult); }
public void Get_NotFound_ReturnsNotFoundResult() { // Act var result = controller.Get(1); // Assert Assert.IsType <NotFoundResult>(result); }
public async Task ReadListCustomer_ShouldReturnHttpStatusCode200AndCountValue4() { HttpJsonApiResult <IEnumerable <CustomerModel> > data = await _customerController.Get() as HttpJsonApiResult <IEnumerable <CustomerModel> >; Assert.AreEqual(data.StatusCode, HttpStatusCode.OK); Assert.AreEqual(new List <CustomerModel>(data.DataValue).Count, 4); }
public void Task_GetCustomerByName_Returns_CustomerDetailsWithOkayStatusCode(string name) { //Act mockcustomerdata.Setup(x => x.GetCustomerByName(name)).Returns(new Customer()); //Assert var data = _controller.Get(name); Assert.IsType <OkObjectResult>(data); }
public void When_Get_Method_Is_Empty_Than_It_Returns_Customer_List_Is_Empty() { _mockCustomer.Setup(customer => customer.GetCustomer()).Returns <Customer>(null); var result = _controller.Get(); var BadResult = result as BadRequestObjectResult; var value = Convert.ToString(BadResult.Value); //Assert Assert.Equal("{ message = Customer List is Empty }", value); }
public void Get_Customers() { // Arrange var actualCustomers = CustomerData.GetCustomers(); _customerServiceMock.Setup(x => x.GetCustomers()).Returns(actualCustomers); // Act var expectedCustomers = _customerController.Get(); // Assert expectedCustomers.ShouldBeEquivalentTo(actualCustomers); }
public async Task GetCustomer_Should_Return_Customer1() { IActionResult actionResult = await customerApi.Get(new InquiryCriteriaDto() { CustomerID = 1 }); Assert.IsNotNull(actionResult); OkObjectResult result = actionResult as OkObjectResult; Assert.IsNotNull(result); Assert.AreEqual(((CustomerDto)result.Value).customerID, 1); }
public async void Task_Return_GetAllBrands() { var controller = new CustomerController(context); var data = await controller.Get(); Assert.IsType <OkObjectResult>(data); }
public void Get_All_Success() { // Arrange CustomerItem item = new CustomerItem() { Id = "5c012842f8e2708cf041e247", Name = "Caisse_01" }; IEnumerable <CustomerItem> items = new List <CustomerItem>() { item }; _customerServicesMock.Setup(x => x.GetCustomerList()).Returns(Task.FromResult(items)); // Act CustomerController controller = new CustomerController(_customerServicesMock.Object, _customerFlowValidMock.Object); ActionResult actionResult = controller.Get().Result; // Assert. Assert.IsType <OkObjectResult>(actionResult); OkObjectResult actionResultType = actionResult as OkObjectResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.OK); Assert.Equal(((List <CustomerItem>)actionResultType.Value), ((List <CustomerItem>)items.ToList())); }
public void TestGetAllList() { CustomerController cc = new CustomerController(); List <Customer> cList = cc.Get(); Assert.AreEqual(4, cList.Count); }
public async Task Get_Success_FirstName( string name, Customer customer, [Frozen] Mock <IEntityRepository <Customer> > customerRepository, CustomerController customerController) { // Arrange customer.FirstName = name; customerRepository .Setup(c => c.FindEntity(It.IsAny <Expression <Func <Customer, bool> > >())) .ReturnsAsync(customer); // Act var res = await customerController.Get(name); // Assert res.Should().NotBeNull(); res.Result.Should().BeOfType <OkObjectResult>(); var okRes = ((OkObjectResult)res.Result); okRes.StatusCode.Should().Be(200); okRes.Value.Should().BeOfType <CustomerModel>(); var resModel = (CustomerModel)okRes.Value; resModel.Should().BeEquivalentTo(customer); }
private void firstBooking() { //Arrange CustomerController cusctr = new CustomerController(); EmployeeController empctr = new EmployeeController(); EscapeRoomController escctr = new EscapeRoomController(); BookingController bookctr = new BookingController(); Customer cus = cusctr.Get("SirLol"); Employee emp = empctr.Get(1); EscapeRoom er = escctr.GetForOwner(3); Booking checkBook; Booking book = new Booking { amountOfPeople = 5, bookingTime = new TimeSpan(16, 00, 0000), cus = cus, date = DateTime.Now.AddDays(14).Date, emp = emp, er = er, }; //Act autoEvent.WaitOne(); bookctr.Create(book.emp.employeeID, book.cus.username, book.er.escapeRoomID, book.bookingTime, book.amountOfPeople, book.date); checkBook = bookctr.Get(er.escapeRoomID, cus.username, book.date); //Assert Assert.AreNotEqual(book.amountOfPeople, checkBook.amountOfPeople); autoEvent.Set(); }
public async Task GivenCreatedCustomerAndAmendedCustomerWhenGetByCustomerIdCheckReturnsDetails() { var customerController = new CustomerController(_customerService); var createCustomerDto = new CustomerControllerDto.RequestCreate { Forename = "John", Surname = "Doe", EmailAddress = "*****@*****.**", Password = "******" }; var createdCustomerId = await customerController.CreateCustomer(createCustomerDto); Assert.IsTrue(createdCustomerId > 0); var updateCustomerDto = new CustomerControllerDto.RequestUpdate { CustomerId = createdCustomerId, Forename = "John", Surname = "Doe", EmailAddress = "*****@*****.**", Password = "******" }; await customerController.UpdateCustomer(updateCustomerDto); var customerResponse = await customerController.Get(createdCustomerId); Assert.IsNotNull(customerResponse); Assert.AreEqual(createCustomerDto.Forename, customerResponse.Forename); Assert.AreEqual(createCustomerDto.Surname, customerResponse.Surname); Assert.AreEqual(createCustomerDto.EmailAddress, customerResponse.EmailAddress); }
public void GetByIDTest() { //Arrange var repository = new Mock <ICustomerRepository>(); var customer = new CustomerDTO { Id = 10, FirstName = "Søren", LastName = "Larsen", Address = "Larsenvej 3", Email = "Sø[email protected]", Phone = "90876653", ZipCode = "9000", City = "Aalborg" }; repository.Setup(x => x.GetById(It.IsAny <int>())).Returns(customer); var controller = new CustomerController(repository.Object); //Act var c = repository.Object.GetById(10); var result = controller.Get(10); var okResult = result as OkObjectResult; //Assert Assert.IsNotNull(c); Assert.AreEqual(customer.Id, c.Id); Assert.IsNotNull(result); Assert.AreEqual(okResult.StatusCode, (int)HttpStatusCode.OK); }
public async Task GetWithFilterQueryShouldBeOkadasd() { // Arrange string filters = "id>2"; string sorts = string.Empty; int page = 1; int pageSize = 100; string fields = string.Empty; var _repositoryMock = new Mock <ICustomerRepository>(); //_repositoryMock.Setup(mock => mock.GetAsync(filters, sorts, page, pageSize, fields)) // .Returns(Task.FromResult(new CustomerResponse // { // Page = 1, // PageSize = 100, // TotalItems = 2, // Entities = new List<Customer> // { // new Customer { Id = 1, Name = "Customer 01", Jurisdiction = "CA", Active = true }, // new Customer { Id = 2, Name = "Customer 02", Jurisdiction = "CA", Active = true } // } // })); var _controller = new CustomerController(new CustomerRepository(Configuration));//_repositoryMock.Object); // Act var result = await _controller.Get(filters, sorts, page, pageSize, fields); // Assert var okResult = result.Should().BeOfType <Microsoft.AspNetCore.Mvc.JsonResult>().Subject; var customerResponse = result.Value.Should().BeAssignableTo <CustomerResponse>().Subject; //customerResponse.Entities.Count.Should().Be(1); }
public void TestMethod1() { CustomerController cc = new CustomerController(); List <Customer> cList = cc.Get(); Assert.AreEqual(6, cList.Count); }
public async Task ServiceTestGetCustomersNoData() { SampleData Data = new SampleData(false); Mock <BookingSystemDb> MockDb = Data.Context(); Mock <DbSet <Company> > MockCompanySet = data.Companies; Mock <DbSet <Restaurant> > MockRestaurantsSet = data.Restaurants; Mock <DbSet <RestaurantMenuItem> > MockRestaurantMenuItemsSet = data.RestaurantMenuItems; Mock <DbSet <MenuItem> > MockMenuItemsSet = data.MenuItems; Mock <DbSet <MenuItemDietInfo> > MockMenuItemDietInfoSet = data.MenuItemDietInfos; Mock <DbSet <DietInfo> > MockDietInfoSet = data.DietInfos; Mock <DbSet <MenuItemType> > MockMenuItemTypeSet = data.MenuItemTypes; Mock <DbSet <DatabaseContext.Data.Type> > MockTypesSet = data.Types; Mock <DbSet <Table> > MockTablesSet = data.Tables; Mock <DbSet <TableBooking> > MockTableBookingSet = data.TableBookings; Mock <DbSet <Booking> > MockBookingSet = data.Bookings; Mock <DbSet <BookingMenuItem> > MockBookingMenuItemsSet = data.BookingMenuItems; Mock <DbSet <Payment> > MockPaymentsSet = data.Payments; Mock <DbSet <PaymentMethod> > MockPaymentMethodsSet = data.PaymentMethods; Mock <DbSet <Customer> > MockCustomersSet = data.Customers; CustomerController Controller = new CustomerController(MockDb.Object) { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; HttpResponseMessage response = await Controller.Get(1); Assert.IsTrue(response.IsSuccessStatusCode); Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent); }
private void secondBooking() { //Arrange CustomerController cusctr2 = new CustomerController(); EmployeeController empctr2 = new EmployeeController(); EscapeRoomController escctr2 = new EscapeRoomController(); BookingController bookctr2 = new BookingController(); Customer cus2 = cusctr2.Get("Anorak"); Employee emp2 = empctr2.Get(1); EscapeRoom er2 = escctr2.GetForOwner(3); Booking checkBook2; Booking book2 = new Booking { amountOfPeople = 2, bookingTime = new TimeSpan(16, 00, 0000), cus = cus2, date = DateTime.Now.AddDays(14).Date, emp = emp2, er = er2, }; //Act bookctr2.Create(book2.emp.employeeID, book2.cus.username, book2.er.escapeRoomID, book2.bookingTime, book2.amountOfPeople, book2.date); checkBook2 = bookctr2.Get(er2.escapeRoomID, cus2.username, book2.date); //Assert Assert.AreEqual(book2.amountOfPeople, checkBook2.amountOfPeople); autoEvent.Set(); autoEvent.WaitOne(); bookctr2.Delete(book2.emp.employeeID, book2.cus.username, book2.er.escapeRoomID, book2.bookingTime, book2.amountOfPeople, book2.date); }
public async void Task_GetCategoryById_Return_BadResquest() { var controller = new CustomerController(context); int?id = null; var data = await controller.Get(id); Assert.IsType <BadRequestResult>(data); }
public void Get_ShouldReturnOneCustomer() { var customers = sut.Get(); Assert.IsNotNull(customers); Assert.AreEqual(1, customers.Count()); Assert.AreEqual("*****@*****.**", customers.FirstOrDefault().Email); }
public void GetAllCustomersTest() { CustomerController customerController = new CustomerController(); string result = customerController.Get(); Assert.IsTrue(result.Count() > 0); }
public void GetAllCustomers_ShouldReturnAllCustomers() { var controller = new CustomerController(); var testCustomers = GetTestProducts(); var result = controller.Get(); Assert.AreEqual(testCustomers.Count, result.Count); }
public async void Task_Get_Return_OkResult() { var controller = new CustomerController(context); var CustomerId = 1; var data = await controller.Get(CustomerId); Assert.IsType <OkObjectResult>(data); }
public async void Task_Get_Return_NotFoundResult() { var controller = new CustomerController(context); var CustomerId = 100; var data = await controller.Get(CustomerId); Assert.IsType <NotFoundResult>(data); }
public void Get_All_Customers() { _customerServiceMock.Setup(x => x.GetCustomers()).Returns(new List <Customer>()); var actualResult = _customerController.Get(); actualResult.Should().NotBeNull(); _customerServiceMock.Verify(x => x.GetCustomers()); }
private void CustomerUpdateForm_Load(object sender, EventArgs e) { txtCustomerName.Text = _customer.CustomerName; txtCustomerLastName.Text = _customer.CustomerLastName; txtCustomerIdentity.Text = _customer.IdentityNumber; _customer = _cuc.Get(_customer.CustomerId); CustomerContactlist(); }
public void TestMethod3() { CustomerController cc = new CustomerController(); Customer c = new Customer("Ny", "Ny", 1988); List<Customer> cList = cc.Get(); int preCount = cList.Count; cc.InsertCustomer(c); Assert.AreEqual(preCount + 1, cList.Count); }
private static void Main(string[] args) { const int TotalRun = 10 * 1000; var customerController = new CustomerController(); var orderController = new OrderController(); var customer = customerController.Get(1); var orders = new List <Order>(); foreach (var orderId in customer.OrderIds) { orders.Add(orderController.Get(1, orderId)); } var fullCustomer = new FullCustomer(customer) { Orders = orders }; var s = JsonConvert.SerializeObject(fullCustomer); var bytes = Encoding.UTF8.GetBytes(s); var stream = new MemoryStream(bytes); var content = new StreamContent(stream); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var stopwatch = Stopwatch.StartNew(); for (int i = 1; i < TotalRun + 1; i++) { var a = content.ReadAsAsync <FullCustomer>().Result; if (i % 100 == 0) { Console.Write("\r" + i); } } Console.WriteLine(); Console.WriteLine(stopwatch.Elapsed); stopwatch.Restart(); for (int i = 1; i < TotalRun + 1; i++) { var sa = content.ReadAsStringAsync().Result; var a = JsonConvert.DeserializeObject <FullCustomer>(sa); if (i % 100 == 0) { Console.Write("\r" + i); } } Console.WriteLine(); Console.WriteLine(stopwatch.Elapsed); Console.Read(); }