public async Task Test_TraktDevice_Equals() { var traktDevice1 = new TraktDevice(); var traktDevice2 = new TraktDevice(); traktDevice1.Equals(traktDevice2).Should().BeTrue(); var jsonReader = new DeviceObjectJsonReader(); var traktDeviceFromJson = await jsonReader.ReadObjectAsync(JSON) as TraktDevice; traktDevice1 = CopyTraktDevice(traktDeviceFromJson); traktDevice2 = CopyTraktDevice(traktDeviceFromJson); traktDevice2.Equals(traktDevice1).Should().BeTrue(); traktDevice1 = CopyTraktDevice(traktDeviceFromJson); traktDevice1.DeviceCode = null; traktDevice2.Equals(traktDevice1).Should().BeFalse(); traktDevice1 = CopyTraktDevice(traktDeviceFromJson); traktDevice1.UserCode = null; traktDevice2.Equals(traktDevice1).Should().BeFalse(); traktDevice1 = CopyTraktDevice(traktDeviceFromJson); traktDevice1.VerificationUrl = null; traktDevice2.Equals(traktDevice1).Should().BeFalse(); traktDevice1 = CopyTraktDevice(traktDeviceFromJson); traktDevice1.ExpiresInSeconds = 0; traktDevice2.Equals(traktDevice1).Should().BeFalse(); traktDevice1 = CopyTraktDevice(traktDeviceFromJson); traktDevice1.IntervalInSeconds = 0; traktDevice2.Equals(traktDevice1).Should().BeFalse(); }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_JsonReader_Null() { var objectJsonReader = new DeviceObjectJsonReader(); ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(default(JsonTextReader)); traktDevice.Should().BeNull(); }
public void Test_DeviceObjectJsonReader_ReadObject_From_Stream_Null() { var objectJsonReader = new DeviceObjectJsonReader(); Func <Task <ITraktDevice> > traktDevice = () => objectJsonReader.ReadObjectAsync(default(Stream)); traktDevice.Should().Throw <ArgumentNullException>(); }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_Json_String_Empty() { var objectJsonReader = new DeviceObjectJsonReader(); ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(string.Empty); traktDevice.Should().BeNull(); }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_Stream_Empty() { var objectJsonReader = new DeviceObjectJsonReader(); using (var stream = string.Empty.ToStream()) { ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(stream); traktDevice.Should().BeNull(); } }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_JsonReader_Empty() { var objectJsonReader = new DeviceObjectJsonReader(); using (var reader = new StringReader(string.Empty)) using (var jsonReader = new JsonTextReader(reader)) { ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(jsonReader); traktDevice.Should().BeNull(); } }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_Json_String_Incomplete_6() { var objectJsonReader = new DeviceObjectJsonReader(); ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(JSON_INCOMPLETE_6); traktDevice.Should().NotBeNull(); traktDevice.DeviceCode.Should().Be("mockDeviceCode"); traktDevice.UserCode.Should().BeNull(); traktDevice.VerificationUrl.Should().BeNull(); traktDevice.ExpiresInSeconds.Should().Be(0); traktDevice.IntervalInSeconds.Should().Be(0); }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_Json_String_Not_Valid_6() { var objectJsonReader = new DeviceObjectJsonReader(); ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(JSON_NOT_VALID_6); traktDevice.Should().NotBeNull(); traktDevice.DeviceCode.Should().BeNull(); traktDevice.UserCode.Should().BeNull(); traktDevice.VerificationUrl.Should().BeNull(); traktDevice.ExpiresInSeconds.Should().Be(0); traktDevice.IntervalInSeconds.Should().Be(0); }
public async Task Test_TraktDevice_From_Json() { var jsonReader = new DeviceObjectJsonReader(); var traktDevice = await jsonReader.ReadObjectAsync(JSON) as TraktDevice; traktDevice.Should().NotBeNull(); traktDevice.DeviceCode.Should().Be("194e624d66681668632a29292d72b87cb02d4e231d428d3136e596af9e5f942f"); traktDevice.UserCode.Should().Be("0F843E93"); traktDevice.VerificationUrl.Should().Be("https://trakt.tv/activate"); traktDevice.ExpiresInSeconds.Should().Be(600U); traktDevice.IntervalInSeconds.Should().Be(5U); traktDevice.IntervalInMilliseconds.Should().Be(5000U); traktDevice.IsValid.Should().BeTrue(); traktDevice.IsExpiredUnused.Should().BeFalse(); traktDevice.CreatedAt.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromMilliseconds(1000)); }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_Stream_Incomplete_4() { var objectJsonReader = new DeviceObjectJsonReader(); using (var stream = JSON_INCOMPLETE_4.ToStream()) { ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(stream); traktDevice.Should().NotBeNull(); traktDevice.DeviceCode.Should().Be("mockDeviceCode"); traktDevice.UserCode.Should().Be("mockUserCode"); traktDevice.VerificationUrl.Should().Be("mockUrl"); traktDevice.ExpiresInSeconds.Should().Be(0); traktDevice.IntervalInSeconds.Should().Be(600U); } }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_Stream_Not_Valid_5() { var objectJsonReader = new DeviceObjectJsonReader(); using (var stream = JSON_NOT_VALID_5.ToStream()) { ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(stream); traktDevice.Should().NotBeNull(); traktDevice.DeviceCode.Should().Be("mockDeviceCode"); traktDevice.UserCode.Should().Be("mockUserCode"); traktDevice.VerificationUrl.Should().Be("mockUrl"); traktDevice.ExpiresInSeconds.Should().Be(7200U); traktDevice.IntervalInSeconds.Should().Be(0); } }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_JsonReader_Incomplete_3() { var objectJsonReader = new DeviceObjectJsonReader(); using (var reader = new StringReader(JSON_INCOMPLETE_3)) using (var jsonReader = new JsonTextReader(reader)) { ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(jsonReader); traktDevice.Should().NotBeNull(); traktDevice.DeviceCode.Should().Be("mockDeviceCode"); traktDevice.UserCode.Should().Be("mockUserCode"); traktDevice.VerificationUrl.Should().BeNull(); traktDevice.ExpiresInSeconds.Should().Be(7200U); traktDevice.IntervalInSeconds.Should().Be(600U); } }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_JsonReader_Not_Valid_4() { var objectJsonReader = new DeviceObjectJsonReader(); using (var reader = new StringReader(JSON_NOT_VALID_4)) using (var jsonReader = new JsonTextReader(reader)) { ITraktDevice traktDevice = await objectJsonReader.ReadObjectAsync(jsonReader); traktDevice.Should().NotBeNull(); traktDevice.DeviceCode.Should().Be("mockDeviceCode"); traktDevice.UserCode.Should().Be("mockUserCode"); traktDevice.VerificationUrl.Should().Be("mockUrl"); traktDevice.ExpiresInSeconds.Should().Be(0); traktDevice.IntervalInSeconds.Should().Be(600U); } }
public async Task Test_DeviceObjectJsonReader_ReadObject_From_Json_String_Null() { var objectJsonReader = new DeviceObjectJsonReader(); Func <Task <ITraktDevice> > traktDevice = () => objectJsonReader.ReadObjectAsync(default(string)); await traktDevice.Should().ThrowAsync <ArgumentNullException>(); }