Example #1
0
        public void RegisterGateway_Should_Only_Allow_To_Register_Only_16_Long_Serial_Number()
        {
            //arrange
            var serialNumber = "123456";
            var dataService  = new Mock <IDataService>();

            dataService.Setup(m => m.Gateways).Returns(new List <Gateway>());
            dataService.Setup(m => m.Users).Returns(new List <User>()
            {
                new User()
            });
            var gatewayService = new GatewayService(dataService.Object);

            //assert
            Assert.Throws <IllegallSerialNumberException>(() => gatewayService.RegisterGateway(serialNumber));
        }
Example #2
0
        public void RegisterGateway_Should_Connect_User_To_Gateway()
        {
            //arrange
            var serialNumber = "1234567891234567";
            var dataService  = new Mock <IDataService>();

            dataService.Setup(m => m.Gateways).Returns(new List <Gateway>());
            dataService.Setup(m => m.Users).Returns(new List <User>()
            {
                new User()
            });
            var gatewayService = new GatewayService(dataService.Object);
            //act
            var current = gatewayService.RegisterGateway(serialNumber);

            //assert
            Assert.IsNotNull(current.User);
        }
Example #3
0
        public void RegisterGateway_Should_Set_Status_To_Registered()
        {
            //arrange
            var serialNumber = "1234567891234567";
            var expected     = GatewayStatus.Registered;
            var dataService  = new Mock <IDataService>();

            dataService.Setup(m => m.Gateways).Returns(new List <Gateway>());
            dataService.Setup(m => m.Users).Returns(new List <User>()
            {
                new User()
            });
            var gatewayService = new GatewayService(dataService.Object);
            //act
            var current = gatewayService.RegisterGateway(serialNumber);

            //assert
            Assert.AreEqual(current.Status, expected);
        }
Example #4
0
        public void RegisterGateway_Should_Not_Allow_To_Register_The_Gateway_Twice()
        {
            //arrange
            var serialNumber = "1234567891234567";
            var dataService  = new Mock <IDataService>();

            dataService.Setup(m => m.Gateways).Returns(new List <Gateway>()
            {
                new Gateway()
                {
                    SerialNumber = serialNumber
                }
            });
            dataService.Setup(m => m.Users).Returns(new List <User>()
            {
                new User()
            });
            var gatewayService = new GatewayService(dataService.Object);

            //assert
            Assert.Throws <GatewayExistsException>(() => gatewayService.RegisterGateway(serialNumber));
        }