public ActivateShould() { mobilesServiceMock = new Mock <IMobilesService>(); var dateTimeCreatorMock = new Mock <IDateTimeCreator>(); expectedMobileGlobalId = Guid.NewGuid(); expectedOrderGlobalId = Guid.NewGuid(); expectedActivateRequest = new ActivateRequest { ActivationCode = "BAS132" }; expectedOrderDataEntity = new OrderDataEntity { GlobalId = expectedOrderGlobalId, Type = Order.OrderType.Activate.ToString(), State = Order.State.New.ToString(), ActivationCode = expectedActivateRequest.ActivationCode, Name = "Neil Armstrong", ContactPhoneNumber = "0700123456", CreatedAt = new DateTime(2001, 5, 4), UpdatedAt = new DateTime(2002, 6, 5) }; expectedMobile = new Mobile(dateTimeCreatorMock.Object, new MobileDataEntity { State = MobileState.ProcessingActivate.ToString(), Orders = new List <OrderDataEntity> { expectedOrderDataEntity } }); mobileRepositoryMock = new Mock <IRepository <Mobile> >(); monitoringMock = new Mock <IMonitoring>(); mobileRepositoryMock.Setup(x => x.GetById(expectedMobileGlobalId)) .Returns(expectedMobile); mobilesServiceMock.Setup(x => x.Activate(expectedMobileGlobalId, expectedActivateRequest)) .Returns(expectedMobile); sut = new MobilesController(mobilesServiceMock.Object, mobileRepositoryMock.Object, monitoringMock.Object); }
/// <summary> /// 新增訂購資訊 /// </summary> /// <param name="uData"></param> /// <returns></returns> public string NewOrderData(OrderDataEntity uData) { //var isSuccess = true; var errorMsg = string.Empty; uData.orderID = Guid.NewGuid().ToString(); uData.orderLoginuserID = UserInfo.loginuserID; var orders = new List <OrderDataEntity>() { uData }; try { OrderDataAccess.AddOrderData(orders); } catch (Exception ex) { errorMsg = ex.Message.Replace("\n", ""); //isSuccess = false; } return(errorMsg); //return Json(new { isSuccess = isSuccess, errorMsg = errorMsg }, JsonRequestBehavior.AllowGet); }