Пример #1
0
        public void Reset()
        {
            PhoneOrderEntity orderInstance;
            var      factory   = new PhoneOrderEntityFactory();
            Guid     emptyGuid = Guid.Parse("00000000-0000-0000-0000-000000000000");
            DateTime emptyTime = DateTime.FromBinary(0);

            factory.SetName("a", "b");
            factory.SetPhoneNumber("5555");
            factory.SetStreet("444 street");
            factory.SetCity("some city");
            factory.SetZipcode(12345);
            factory.GenerateId();
            factory.GeneratePlacedOnDate();
            factory.SetStatus(PhoneOrderEntity.ApprovalStatus.Open);
            factory.Reset();
            orderInstance = factory.GetInstance();

            Assert.Null(orderInstance.FirstName);
            Assert.Null(orderInstance.LastName);
            Assert.Null(orderInstance.Phone);
            Assert.Null(orderInstance.Street);
            Assert.Null(orderInstance.City);
            Assert.AreEqual(0, orderInstance.Zipcode);
            Assert.NotNull(orderInstance.Id);
            Assert.AreEqual(emptyGuid, orderInstance.Id);
            Assert.NotNull(orderInstance.PlacedOn);
            Assert.AreEqual(emptyTime, orderInstance.PlacedOn);
            Assert.AreEqual(PhoneOrderEntity.ApprovalStatus.PendingApproval, orderInstance.Status);
        }
Пример #2
0
        public void GeneratePlacedOnDate()
        {
            PhoneOrderEntity orderInstance;
            var factory = new PhoneOrderEntityFactory();

            factory.GeneratePlacedOnDate();
            orderInstance = factory.GetInstance();

            Assert.NotNull(orderInstance.PlacedOn);
        }
Пример #3
0
        public String CreatePhoneOrder(Stream body)
        {
            String           json        = getJsonFromBody(body);
            ResponseDTO      responseDTO = new ResponseDTO();
            PhoneOrderEntity order;

            phoneOrderEntityFactory.FromJson(json);
            phoneOrderEntityFactory.GenerateId();
            phoneOrderEntityFactory.GeneratePlacedOnDate();
            phoneOrderEntityFactory.SetStatus(PhoneOrderEntity.ApprovalStatus.Open);
            order = phoneOrderEntityFactory.GetInstance();
            phoneOrderRepository.InsertPhoneOrder(order);

            responseDTO.Result = "Done";
            return(JsonConvert.SerializeObject(responseDTO));
        }