public void GetOrderExFaultTest() { using (var service = ChannelFactoryHelper.GetOrdersFactory(new InstanceContext(this), UserRole.None).CreateChannel()) { var ex = Assert.Catch <FaultException <OrderNotFound> >(() => { service.GetOrderEx(-1); }); Assert.AreEqual(ex.Detail.OrderId, -1); } }
public void IncorrectPasswordTest() { using (var service = ChannelFactoryHelper.GetOrdersFactoryForSecurityTests(new InstanceContext(this), "Operator1", "1234567890").CreateChannel()) { Assert.Catch <CommunicationException>(() => service.GetOrders()); if (service.State == CommunicationState.Faulted) { service.Abort(); } } }
public void NonExistsUserTest() { using (var service = ChannelFactoryHelper.GetOrdersFactoryForSecurityTests(new InstanceContext(this), "Ivan", "123456").CreateChannel()) { Assert.Catch <CommunicationException>(() => service.GetOrders()); if (service.State == CommunicationState.Faulted) { service.Abort(); } } }
public void AccessDeniedTest() { using (var service = ChannelFactoryHelper.GetOrdersFactory(new InstanceContext(this), UserRole.Operator).CreateChannel()) { var order = new OrdersHelper().AddOrder(); Assert.Catch <SecurityAccessDeniedException>(() => service.SendOrderToProcess(order.OrderID, DateTime.Now.AddDays(1))); if (service.State == CommunicationState.Faulted) { service.Abort(); } } }
public void SendOrderToCustomerFaultTest() { var order = new OrdersHelper().AddOrder(); using (var service = ChannelFactoryHelper.GetOrdersFactory(new InstanceContext(this), UserRole.Manager).CreateChannel()) { var processedOrder = service.SendOrderToProcess(order.OrderID, DateTime.Now); var shippedOrder = service.SendOrderToCustomer(processedOrder.OrderID, DateTime.Now.AddDays(7)); var ex = Assert.Catch <FaultException <OrderNotInRequiredStatuses> >(() => { service.SendOrderToCustomer(shippedOrder.OrderID, DateTime.Now.AddDays(10)); }); Assert.True(ex.Detail.RequiredStatuses.Contains(OrderStatus.InProgress) && ex.Detail.RequiredStatuses.Length == 1); } }
public void SendOrderToProcessFaultTest() { var order = new OrdersHelper().AddOrder(); using (var service = ChannelFactoryHelper.GetOrdersFactory(new InstanceContext(this), UserRole.Manager).CreateChannel()) { var processedOrder = service.SendOrderToProcess(order.OrderID, DateTime.Now); var invalidStatusEx = Assert.Catch <FaultException <OrderNotInRequiredStatuses> >(() => { service.SendOrderToProcess(processedOrder.OrderID, DateTime.Now); }); Assert.True(invalidStatusEx.Detail.RequiredStatuses.Contains(OrderStatus.New) && invalidStatusEx.Detail.RequiredStatuses.Length == 1); var invalidDateEx = Assert.Catch <FaultException <InvalidOrderDate> >(() => { service.SendOrderToProcess(processedOrder.OrderID, DateTime.Now.AddDays(-7)); }); Assert.AreEqual(invalidDateEx.Detail.OrderId, processedOrder.OrderID); } }
public void UpdateOrderFaultTest() { var order = new OrdersHelper().AddOrder(); using (var service = ChannelFactoryHelper.GetOrdersFactory(new InstanceContext(this), UserRole.Operator | UserRole.Manager).CreateChannel()) { var oldId = order.OrderID; order.OrderID = -100; Assert.Catch <FaultException <OrderNotFound> >(() => { service.UpdateOrder(order); }); order.OrderID = oldId; order = service.SendOrderToProcess(order.OrderID, DateTime.Now); Assert.Catch <FaultException <OrderNotInRequiredStatuses> >(() => { service.UpdateOrder(order); }); } }
public void GetOrderEx() { Order fullOrderData = null; var service = ChannelFactoryHelper.GetOrdersFactory(new InstanceContext(this)).CreateChannel(); try { var orderId = service.GetOrders().First().OrderID; fullOrderData = service.GetOrderEx(orderId); } catch { if (service.State == CommunicationState.Faulted) { service.Abort(); } } service.Close(); Assert.NotNull(fullOrderData); }