Ejemplo n.º 1
0
        public void IRepository_Mapping_IoC_Repository()
        {
            var svc = new DeviceService().AddDeviceFn(new DeviceRepository());


            var cmd = new CreateDevice
            {
                BluetoothName = "HK_Living",
                Generation    = 1,
                SerialNumber  = "ABC123"
            };

            var result = svc(cmd).Result;

            Assert.True(result.HasValue);
            var emp = result.GetOrElse(new DeviceRegistered());

            Assert.True(emp.Name.Contains(cmd.BluetoothName));
        }
Ejemplo n.º 2
0
        public void Simple_Func_Mapping_IoC_Repository()
        {
            Func <Device, Task <Result <Device> > > repo = new DeviceRepository().Save;
            var svc = new DeviceService();

            var cmd = new CreateDevice
            {
                BluetoothName = "HK_Living",
                Generation    = 1,
                SerialNumber  = "ABC123"
            };

            var result = svc.Add(repo, cmd).Result;

            Assert.True(result.HasValue);
            var emp = result.GetOrElse(new DeviceRegistered());

            Assert.True(emp.Name.Contains(cmd.BluetoothName));
        }
Ejemplo n.º 3
0
        public async void IRepository_With_Reader_As_IoC_Repository()
        {
            var svc = new DeviceService();


            var cmd = new CreateDevice
            {
                BluetoothName = "HK_Living",
                Generation    = 1,
                SerialNumber  = "ABC123"
            };

            var result = await svc.AddDeviceWithReaderMonad(cmd)
                         .Run(new DeviceRepository());

            Assert.True(result.HasValue);
            var emp = result.GetOrElse(new DeviceRegistered());

            Assert.True(emp.Name.Contains(cmd.BluetoothName));
        }