Beispiel #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);
        }
Beispiel #2
0
        public void GetInstance()
        {
            PhoneOrderEntity orderInstance;
            var factory = new PhoneOrderEntityFactory();

            orderInstance = factory.GetInstance();

            Assert.NotNull(orderInstance);
        }
Beispiel #3
0
        public void GeneratePlacedOnDate()
        {
            PhoneOrderEntity orderInstance;
            var factory = new PhoneOrderEntityFactory();

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

            Assert.NotNull(orderInstance.PlacedOn);
        }
Beispiel #4
0
        public void SetPlacedOnDate()
        {
            PhoneOrderEntity orderInstance;
            var factory = new PhoneOrderEntityFactory();
            var time    = DateTime.UtcNow;

            factory.SetPlacedOnDate(time);
            orderInstance = factory.GetInstance();

            Assert.AreEqual(time, orderInstance.PlacedOn);
        }
Beispiel #5
0
        public void SetOrderStatus()
        {
            PhoneOrderEntity orderInstance;
            var factory = new PhoneOrderEntityFactory();
            const PhoneOrderEntity.ApprovalStatus status = PhoneOrderEntity.ApprovalStatus.Open;

            factory.SetStatus(status);
            orderInstance = factory.GetInstance();

            Assert.AreEqual(status, orderInstance.Status);
        }
Beispiel #6
0
        public void SetPhoneNumber()
        {
            PhoneOrderEntity orderInstance;
            var          factory     = new PhoneOrderEntityFactory();
            const String phoneNumber = "555-555-5555";

            factory.SetPhoneNumber(phoneNumber);
            orderInstance = factory.GetInstance();

            Assert.AreEqual(phoneNumber, orderInstance.Phone);
        }
Beispiel #7
0
        public void SetZipCode()
        {
            PhoneOrderEntity orderInstance;
            var          factory = new PhoneOrderEntityFactory();
            const UInt32 zip     = 12345;

            factory.SetZipcode(zip);
            orderInstance = factory.GetInstance();

            Assert.AreEqual(zip, orderInstance.Zipcode);
        }
Beispiel #8
0
        public void SetCity()
        {
            PhoneOrderEntity orderInstance;
            var          factory = new PhoneOrderEntityFactory();
            const String city    = "San Diego";

            factory.SetCity(city);
            orderInstance = factory.GetInstance();

            Assert.AreEqual(city, orderInstance.City);
        }
Beispiel #9
0
        public void SetStreet()
        {
            PhoneOrderEntity orderInstance;
            var          factory = new PhoneOrderEntityFactory();
            const String street  = "555 Happy Street";

            factory.SetStreet(street);
            orderInstance = factory.GetInstance();

            Assert.AreEqual(street, orderInstance.Street);
        }
Beispiel #10
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));
        }
Beispiel #11
0
        public void ReadFromJson()
        {
            PhoneOrderEntity orderInstance;
            var          factory = new PhoneOrderEntityFactory();
            const String json    = "{\"first_name\":\"John\",\"last_name\":\"Smith\"}";

            factory.FromJson(json);
            orderInstance = factory.GetInstance();

            Assert.AreEqual("John", orderInstance.FirstName);
            Assert.AreEqual("Smith", orderInstance.LastName);
        }
Beispiel #12
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);
        }
Beispiel #13
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);
        }