Ejemplo n.º 1
0
        public void GetWatchesShouldThrowExceptionForInvalidWatch(int watchtype, int brandname, int straptype, int strapcolor, int segment)
        {
            string       watchType  = "AnalogWatch";
            string       brandName  = "TITAN";
            string       strapType  = "METALIC";
            string       strapColor = "BLACK";
            string       Segment    = "BASIC";
            List <Watch> watches    = new List <Watch>();
            var          mockRepo   = new Mock <IWatchRepository>();

            mockRepo.Setup(repo => repo.GetWatches(watchType, brandName, strapType, strapColor, Segment)).Returns(watches);
            WatchService watchService = new WatchService(mockRepo.Object);
            var          actual       = Assert.Throws <NoMatchFoundException>(() => watchService.GetWatches(watchtype, brandname, straptype, strapcolor, segment));

            Assert.AreEqual("No Match Found, Please Try Another Combination", actual.Message);
        }
Ejemplo n.º 2
0
        public void GetWatchesShouldReturnDigitalWatch()
        {
            string       watchType  = "DigitalWatch";
            string       brandName  = "TITAN";
            string       strapType  = "METALIC";
            string       strapColor = "BLACK";
            string       Segment    = "BASIC";
            List <Watch> watches    = new List <Watch> {
                new DigitalWatch {
                    WatchId = 2111, BrandName = "TITAN", StrapType = "METALIC", StrapColor = "BLACK", Segment = "BASIC", Price = 8000, DisplayMode = "24Hour", HasBackLight = true
                }
            };

            var mockRepo = new Mock <IWatchRepository>();

            mockRepo.Setup(repo => repo.GetWatches(watchType, brandName, strapType, strapColor, Segment)).Returns(watches);
            WatchService watchService = new WatchService(mockRepo.Object);
            var          actual       = watchService.GetWatches(2, 2, 1, 1, 1);

            Assert.IsAssignableFrom <DigitalWatch>(actual);
            Assert.AreEqual("DigitalWatch", actual.GetType().Name);
        }
Ejemplo n.º 3
0
        public void GetWatchesShouldReturnAnalogWatch()
        {
            string       watchType  = "AnalogWatch";
            string       brandName  = "FASTTRACK";
            string       strapType  = "METALIC";
            string       strapColor = "BLACK";
            string       Segment    = "BASIC";
            List <Watch> watches    = new List <Watch> {
                new AnalogWatch()
                {
                    WatchId = 1101, BrandName = "FASTTRACK", StrapType = "METALIC", StrapColor = "BLACK", Segment = "BASIC", Price = 4000, NumberOfHands = 2, HasCalender = false
                }
            };

            var mockRepo = new Mock <IWatchRepository>();

            mockRepo.Setup(repo => repo.GetWatches(watchType, brandName, strapType, strapColor, Segment)).Returns(watches);
            WatchService watchService = new WatchService(mockRepo.Object);
            var          actual       = watchService.GetWatches(1, 1, 1, 1, 1);

            Assert.IsAssignableFrom <AnalogWatch>(actual);
            Assert.AreEqual("AnalogWatch", actual.GetType().Name);
        }