예제 #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 SetName()
        {
            PhoneOrderEntity orderInstance;
            var factory = new PhoneOrderEntityFactory();
            const String
                fname = "John",
                lname = "Smith";

            factory.SetName(fname, lname);
            orderInstance = factory.GetInstance();

            Assert.AreEqual(fname, orderInstance.FirstName);
            Assert.AreEqual(lname, orderInstance.LastName);
        }
예제 #3
0
        public void GetAllRecords()
        {
            PhoneOrderService           phoneOrderService        = new PhoneOrderService();
            List <PhoneOrderEntity>     orders                   = new List <PhoneOrderEntity>();
            PhoneOrderEntityFactory     phoneOrderEntityFactory  = new PhoneOrderEntityFactory();
            Mock <PhoneOrderRepository> mockPhoneOrderRepository = mockFactory.CreateMock <PhoneOrderRepository>();
            const String expectedResult = "{\"result\":\"Done\",\"count\":0,\"orders\":[{\"first_name\":\"John\",\"last_name\":\"Smith\"," +
                                          "\"street\":null,\"city\":null,\"zipcode\":0,\"phone_number\":null,\"status\":0,\"id\":\"00000000-0000-0000-0000-000000000000\"," +
                                          "\"placed_on\":\"0001-01-01T00:00:00\"}]}";

            phoneOrderEntityFactory.SetName("John", "Smith");
            orders.Add(phoneOrderEntityFactory.GetInstance());
            mockPhoneOrderRepository.Expects.One.Method(x => x.GetOrderList()).WillReturn(orders);
            phoneOrderService.SetPrivateField("phoneOrderRepository", mockPhoneOrderRepository.MockObject);

            String response = phoneOrderService.GetAllRecords();

            Assert.AreEqual(expectedResult, response);
        }
예제 #4
0
        public String CreateDefaultOrder()
        {
            ResponseDTO responseDTO = new ResponseDTO();

            phoneOrderEntityFactory.GenerateId();
            phoneOrderEntityFactory.SetName("John", "Smith");
            phoneOrderEntityFactory.SetStreet("356 Rosewood");
            phoneOrderEntityFactory.SetCity("Happyville");
            phoneOrderEntityFactory.SetZipcode(31415);
            phoneOrderEntityFactory.SetPhoneNumber("555-5555");
            phoneOrderEntityFactory.SetStatus(PhoneOrderEntity.ApprovalStatus.Open);
            phoneOrderEntityFactory.SetPlacedOnDate(DateTime.Now);
            PhoneOrderEntity defaultOrder = phoneOrderEntityFactory.GetInstance();

            phoneOrderRepository.InsertPhoneOrder(defaultOrder);

            responseDTO.Result = "Done";

            return(JsonConvert.SerializeObject(responseDTO));
        }