Beispiel #1
0
        public void PushTest()
        {
            DeviceData device = new DeviceData()
            {
                Serial = "169.254.109.177:5555",
                State  = DeviceState.Online
            };

            Stream stream         = File.OpenRead("fstab.bin");
            var    content        = File.ReadAllBytes("fstab.bin");
            var    contentMessage = new List <byte>();

            contentMessage.AddRange(SyncCommandConverter.GetBytes(SyncCommand.DATA));
            contentMessage.AddRange(BitConverter.GetBytes(content.Length));
            contentMessage.AddRange(content);

            this.RunTest(
                OkResponses(2),
                ResponseMessages(),
                Requests("host:transport:169.254.109.177:5555", "sync:"),
                SyncRequests(
                    SyncCommand.SEND, "/sdcard/test,644",
                    SyncCommand.DONE, "1446505200"),
                new SyncCommand[] { SyncCommand.OKAY },
                null,
                new byte[][]
            {
                contentMessage.ToArray()
            },
                () =>
            {
                using (SyncService service = new SyncService(this.Socket, device))
                {
                    service.Push(stream, "/sdcard/test", 0644, new DateTime(2015, 11, 2, 23, 0, 0, DateTimeKind.Utc), null, CancellationToken.None);
                }
            });
        }
 public void GetBytesInvalidCommandTest()
 {
     SyncCommandConverter.GetBytes((SyncCommand)99);
 }
 public void GetCommandInvalidNumberOfBytesTest()
 {
     SyncCommandConverter.GetCommand(new byte[] { });
 }
 public void GetCommandInvalidCommandTest()
 {
     SyncCommandConverter.GetCommand(new byte[] { (byte)'Q', (byte)'M', (byte)'T', (byte)'V' });
 }
 public void GetCommandNullTest()
 {
     SyncCommandConverter.GetCommand(null);
 }
Beispiel #6
0
 public void GetCommandNullTest()
 {
     Assert.Throws <ArgumentNullException>(() => SyncCommandConverter.GetCommand(null));
 }
Beispiel #7
0
 public void GetBytesInvalidCommandTest()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => SyncCommandConverter.GetBytes((SyncCommand)99));
 }
Beispiel #8
0
 public void GetCommandInvalidCommandTest()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => SyncCommandConverter.GetCommand(new byte[] { (byte)'Q', (byte)'M', (byte)'T', (byte)'V' }));
 }
Beispiel #9
0
 public void GetCommandInvalidNumberOfBytesTest()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => SyncCommandConverter.GetCommand(new byte[] { }));
 }