Here are the examples of the csharp api System.DateTimeOffset.Parse(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
219 Examples
19
Source : AzureBlobFileStorage.cs
with Apache License 2.0
from aloneguid
with Apache License 2.0
from aloneguid
private static IEnumerable<IOEntry> ConvertBatch(XElement blobs)
{
foreach(XElement blobPrefix in blobs.Elements("BlobPrefix"))
{
string name = blobPrefix.Element("Name").Value;
yield return new IOEntry(name + IOPath.PathSeparatorString);
}
foreach(XElement blob in blobs.Elements("Blob"))
{
string name = blob.Element("Name").Value;
var file = new IOEntry(name);
foreach(XElement xp in blob.Element("Properties").Elements())
{
string pname = xp.Name.ToString();
string pvalue = xp.Value;
if(!string.IsNullOrEmpty(pvalue))
{
if(pname == "Last-Modified")
{
file.LastModificationTime = DateTimeOffset.Parse(pvalue);
}
else if(pname == "Content-Length")
{
file.Size = long.Parse(pvalue);
}
else if(pname == "Content-MD5")
{
file.MD5 = pvalue;
}
else
{
file.Properties[pname] = pvalue;
}
}
}
yield return file;
}
}
19
Source : XmlResponseParser.cs
with Apache License 2.0
from aloneguid
with Apache License 2.0
from aloneguid
public IReadOnlyCollection<IOEntry> ParseListObjectV2Response(string xml, out string continuationToken)
{
continuationToken = null;
var result = new List<IOEntry>();
using(var sr = new StringReader(xml))
{
using(var xr = XmlReader.Create(sr))
{
string en = null;
while(xr.Read())
{
if(xr.NodeType == XmlNodeType.Element)
{
switch(xr.Name)
{
case "Contents":
string key = null;
string lastMod = null;
string eTag = null;
string size = null;
string storageClreplaced = null;
// read all the elements in this
while(xr.Read() && !(xr.NodeType == XmlNodeType.EndElement && xr.Name == "Contents"))
{
if(xr.NodeType == XmlNodeType.Element)
en = xr.Name;
else if(xr.NodeType == XmlNodeType.Text)
{
switch(en)
{
case "Key":
key = xr.Value;
break;
case "LastModified":
lastMod = xr.Value;
break;
case "ETag":
eTag = xr.Value;
break;
case "Size":
size = xr.Value;
break;
case "StorageClreplaced":
storageClreplaced = xr.Value;
break;
}
}
}
if(key != null)
{
var entry = new IOEntry(key)
{
LastModificationTime = DateTimeOffset.Parse(lastMod),
Size = int.Parse(size)
};
entry.TryAddProperties(
"ETag", eTag,
"StorageClreplaced", storageClreplaced);
result.Add(entry);
}
break;
case "CommonPrefixes":
while(xr.Read() && !(xr.NodeType == XmlNodeType.EndElement && xr.Name == "CommonPrefixes"))
{
// <Prefix>foldername/</Prefix>
if(xr.NodeType == XmlNodeType.Element)
en = xr.Name;
else if(xr.NodeType == XmlNodeType.Text)
{
if(en == "Prefix")
{
result.Add(new IOEntry(xr.Value));
}
}
}
break;
case "NextContinuationToken":
throw new NotImplementedException();
}
}
}
}
}
return result;
}
19
Source : CompactJsonFormatTests.cs
with MIT License
from Analogy-LogViewer
with MIT License
from Analogy-LogViewer
[TestMethod]
[DataRow("CompactJsonFormat.clef",4, "2016-10-12T04:46:58.0554314Z")]
[DataRow("CompactJsonFormatSourceContextTest.clef",2, "2020-06-18T18:03:19.2248275Z")]
[DataRow("CompactJsonFormatTestColumns.clef",4, "2020-06-26T14:21:34.7233612Z")]
[DataRow("CompactJsonFormat.gz",4, "2016-10-12T04:46:58.0554314Z")]
public async Task OfflineProviderParserTimestampTest(string fileName,int numberOfMessages,string datetimeToParse)
{
OfflineDataProvider parser = new OfflineDataProvider();
CancellationTokenSource cts = new CancellationTokenSource();
string file = Path.Combine(Folder, "log files", fileName);
MessageHandlerForTesting forTesting = new MessageHandlerForTesting();
var messages = (await parser.Process(file, cts.Token, forTesting)).ToList();
DateTimeOffset dto = DateTimeOffset.Parse(datetimeToParse);
replacedert.IsTrue(messages.Count == numberOfMessages);
replacedert.IsTrue(messages[0].Date == dto.DateTime);
}
19
Source : JsonFormatTests.cs
with MIT License
from Analogy-LogViewer
with MIT License
from Analogy-LogViewer
[TestMethod]
public async Task JsonFilePerLineDateTimeWithOffsetTest()
{
var p = new JsonFormatterParser(new JsonFormatMessageFields());
CancellationTokenSource cts = new CancellationTokenSource();
string fileName = Path.Combine(Folder, "log files", "JsonFormatPerLine.clef");
MessageHandlerForTesting forTesting = new MessageHandlerForTesting();
var messages = (await p.Process(fileName, cts.Token, forTesting)).ToList();
replacedert.IsTrue(messages.Count == 2);
replacedert.IsTrue(messages[0].User == "{ Name: \"nblumhardt\", Tags: [1, 2, 3] }");
DateTimeOffset dto = DateTimeOffset.Parse("2020-06-07T13:44:57.8532799+10:00");
//replacedert.IsTrue(messages[0].Date == dto.DateTime);
//replacedert.IsTrue(messages[0].Text == "Hello, { Name: \"nblumhardt\", Tags: [1, 2, 3] }, 0000007b at 06/07/2016 06:44:57", "got" + messages[0].Text);
}
19
Source : EventParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void ParseExplicit_ValidBlobCreatedEvent_ShouldSucceed()
{
// Arrange
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const string subject = "/blobServices/default/containers/event-container/blobs/finnishjpeg";
const string eventType = "Microsoft.Storage.BlobCreated";
const string id = "5647b67c-b01e-002d-6a47-bc01ac063360";
const string dataVersion = "1";
const string metadataVersion = "1";
const string api = "PutBlockList";
const string clientRequestId = "5c24a322-35c9-4b46-8ef5-245a81af7037";
const string requestId = "5647b67c-b01e-002d-6a47-bc01ac000000";
const string eTag = "0x8D58A5F0C6722F9";
const string contentType = "image/jpeg";
const int contentLength = 29342;
const string blobType = "BlockBlob";
const string url = "https://sample.blob.core.windows.net/event-container/finnish.jpeg";
const string sequencer = "00000000000000000000000000000094000000000017d503";
const string batchId = "69cd1576-e430-4aff-8153-570934a1f6e1";
string rawEvent = EventSamples.BlobCreateEvent;
var eventTime = DateTimeOffset.Parse("2018-03-15T10:25:17.7535274");
// Act
var eventGridMessage = EventParser.Parse(rawEvent);
// replacedert
replacedert.NotNull(eventGridMessage);
replacedert.NotNull(eventGridMessage.Events);
EventGridEvent eventGridEvent = replacedert.Single(eventGridMessage.Events);
replacedert.Equal(topic, eventGridEvent.Topic);
replacedert.Equal(subject, eventGridEvent.Subject);
replacedert.Equal(eventType, eventGridEvent.EventType);
replacedert.Equal(eventTime, eventGridEvent.EventTime);
replacedert.Equal(id, eventGridEvent.Id);
replacedert.Equal(dataVersion, eventGridEvent.DataVersion);
replacedert.Equal(metadataVersion, eventGridEvent.MetadataVersion);
replacedert.NotNull(eventGridEvent.Data);
var eventPayload = eventGridEvent.GetPayload<StorageBlobCreatedEventData>();
replacedert.NotNull(eventPayload);
replacedert.Equal(api, eventPayload.Api);
replacedert.Equal(clientRequestId, eventPayload.ClientRequestId);
replacedert.Equal(requestId, eventPayload.RequestId);
replacedert.Equal(eTag, eventPayload.ETag);
replacedert.Equal(contentType, eventPayload.ContentType);
replacedert.Equal(contentLength, eventPayload.ContentLength);
replacedert.Equal(blobType, eventPayload.BlobType);
replacedert.Equal(url, eventPayload.Url);
replacedert.Equal(sequencer, eventPayload.Sequencer);
replacedert.NotNull(eventPayload.StorageDiagnostics);
var storageDiagnostics = replacedert.IsType<JObject>(eventPayload.StorageDiagnostics);
replacedert.Equal(batchId, storageDiagnostics["batchId"]);
}
19
Source : EventGridParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void Parse_ValidSubscriptionValidationEventWithSessionId_ShouldSucceed()
{
// Arrange
string rawEvent = EventSamples.SubscriptionValidationEvent;
const string eventId = "2d1781af-3a4c-4d7c-bd0c-e34b19da4e66";
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const string subject = "Sample.Subject";
const string eventType = "Microsoft.EventGrid.SubscriptionValidationEvent";
const string validationCode = "512d38b6-c7b8-40c8-89fe-f46f9e9622b6";
var eventTime = DateTimeOffset.Parse("2017-08-06T22:09:30.740323Z");
string sessionId = Guid.NewGuid().ToString();
// Act
var eventGridBatch = EventGridParser.ParseFromData<SubscriptionValidationEventData>(rawEvent, sessionId);
// replacedert
replacedert.NotNull(eventGridBatch);
replacedert.Equal(sessionId, eventGridBatch.SessionId);
replacedert.NotNull(eventGridBatch.Events);
replacedert.Single(eventGridBatch.Events);
var eventPayload = eventGridBatch.Events.Single();
replacedert.Equal(eventId, eventPayload.Id);
replacedert.Equal(topic, eventPayload.Topic);
replacedert.Equal(subject, eventPayload.Subject);
replacedert.Equal(eventType, eventPayload.EventType);
replacedert.Equal(eventTime, eventPayload.EventTime);
replacedert.NotNull(eventPayload.Data);
replacedert.Equal(validationCode, eventPayload.GetPayload()?.ValidationCode);
}
19
Source : EventParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void ParseExplicitAsCloudEvent_ValidBlobCreatedEvent_ShouldSucceed()
{
// Arrange
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
subject = "/blobServices/default/containers/event-container/blobs/finnishjpeg",
eventType = "Microsoft.Storage.BlobCreated",
id = "5647b67c-b01e-002d-6a47-bc01ac063360",
api = "PutBlockList",
clientRequestId = "5c24a322-35c9-4b46-8ef5-245a81af7037",
requestId = "5647b67c-b01e-002d-6a47-bc01ac000000",
eTag = "0x8D58A5F0C6722F9",
contentType = "image/jpeg",
blobType = "BlockBlob",
url = "https://sample.blob.core.windows.net/event-container/finnish.jpeg",
sequencer = "00000000000000000000000000000094000000000017d503",
batchId = "69cd1576-e430-4aff-8153-570934a1f6e1";
const int contentLength = 29342;
var eventTime = DateTimeOffset.Parse("2018-03-15T10:25:17.7535274");
var source = new Uri("/some/source/not/available/in/event-grid/events", UriKind.Relative);
string rawEvent = EventSamples.BlobCreateEvent;
var eventGridEventBatch = EventParser.Parse(rawEvent);
replacedert.NotNull(eventGridEventBatch);
Event @event = replacedert.Single(eventGridEventBatch.Events);
replacedert.NotNull(@event);
// Act
CloudEvent cloudEvent = @event.AsCloudEvent(source);
// replacedert
replacedert.NotNull(cloudEvent);
replacedert.Equal(topic, @event.Topic);
replacedert.Equal(subject, cloudEvent.Subject);
replacedert.Equal(eventType, cloudEvent.Type);
replacedert.Equal(eventTime, cloudEvent.Time.GetValueOrDefault());
replacedert.Equal(id, cloudEvent.Id);
var eventPayload = cloudEvent.GetPayload<StorageBlobCreatedEventData>();
replacedert.NotNull(eventPayload);
replacedert.Equal(api, eventPayload.Api);
replacedert.Equal(clientRequestId, eventPayload.ClientRequestId);
replacedert.Equal(requestId, eventPayload.RequestId);
replacedert.Equal(eTag, eventPayload.ETag);
replacedert.Equal(contentType, eventPayload.ContentType);
replacedert.Equal(contentLength, eventPayload.ContentLength);
replacedert.Equal(blobType, eventPayload.BlobType);
replacedert.Equal(url, eventPayload.Url);
replacedert.Equal(sequencer, eventPayload.Sequencer);
replacedert.NotNull(eventPayload.StorageDiagnostics);
var storageDiagnostics = replacedert.IsType<JObject>(eventPayload.StorageDiagnostics);
replacedert.Equal(batchId, storageDiagnostics["batchId"]);
}
19
Source : EventParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void ParseNewtonsoftJson_ValidBlobCreatedEvent_ShouldSucceed()
{
// Arrange
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
subject = "/blobServices/default/containers/event-container/blobs/finnishjpeg",
eventType = "Microsoft.Storage.BlobCreated",
id = "5647b67c-b01e-002d-6a47-bc01ac063360",
dataVersion = "1",
metadataVersion = "1",
api = "PutBlockList",
clientRequestId = "5c24a322-35c9-4b46-8ef5-245a81af7037",
requestId = "5647b67c-b01e-002d-6a47-bc01ac000000",
eTag = "0x8D58A5F0C6722F9",
contentType = "image/jpeg",
blobType = "BlockBlob",
url = "https://sample.blob.core.windows.net/event-container/finnish.jpeg",
sequencer = "00000000000000000000000000000094000000000017d503",
batchId = "69cd1576-e430-4aff-8153-570934a1f6e1";
const int contentLength = 29342;
var eventTime = DateTimeOffset.Parse("2018-03-15T10:25:17.7535274Z");
string rawEvent = EventSamples.BlobCreateEvent.Trim('[', ']');
// Act
var eventGridEvent = JsonConvert.DeserializeObject<Event>(rawEvent);
// replacedert
replacedert.Equal(topic, eventGridEvent.Topic);
replacedert.Equal(subject, eventGridEvent.Subject);
replacedert.Equal(eventType, eventGridEvent.EventType);
replacedert.Equal(eventTime, eventGridEvent.EventTime);
replacedert.Equal(id, eventGridEvent.Id);
replacedert.Equal(dataVersion, eventGridEvent.DataVersion);
replacedert.Equal(metadataVersion, eventGridEvent.MetadataVersion);
var eventPayload = eventGridEvent.GetPayload<StorageBlobCreatedEventData>();
replacedert.NotNull(eventPayload);
replacedert.Equal(api, eventPayload.Api);
replacedert.Equal(clientRequestId, eventPayload.ClientRequestId);
replacedert.Equal(requestId, eventPayload.RequestId);
replacedert.Equal(eTag, eventPayload.ETag);
replacedert.Equal(contentType, eventPayload.ContentType);
replacedert.Equal(contentLength, eventPayload.ContentLength);
replacedert.Equal(blobType, eventPayload.BlobType);
replacedert.Equal(url, eventPayload.Url);
replacedert.Equal(sequencer, eventPayload.Sequencer);
replacedert.NotNull(eventPayload.StorageDiagnostics);
var storageDiagnostics = replacedert.IsType<JObject>(eventPayload.StorageDiagnostics);
replacedert.Equal(batchId, storageDiagnostics["batchId"]);
}
19
Source : EventParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void Parse_ValidBlobCreatedEvent_ShouldSucceed()
{
// Arrange
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const string subject = "/blobServices/default/containers/event-container/blobs/finnishjpeg";
const string eventType = "Microsoft.Storage.BlobCreated";
const string id = "5647b67c-b01e-002d-6a47-bc01ac063360";
const string dataVersion = "1";
const string metadataVersion = "1";
const string api = "PutBlockList";
const string clientRequestId = "5c24a322-35c9-4b46-8ef5-245a81af7037";
const string requestId = "5647b67c-b01e-002d-6a47-bc01ac000000";
const string eTag = "0x8D58A5F0C6722F9";
const string contentType = "image/jpeg";
const int contentLength = 29342;
const string blobType = "BlockBlob";
const string url = "https://sample.blob.core.windows.net/event-container/finnish.jpeg";
const string sequencer = "00000000000000000000000000000094000000000017d503";
const string batchId = "69cd1576-e430-4aff-8153-570934a1f6e1";
string rawEvent = EventSamples.BlobCreateEvent;
var eventTime = DateTimeOffset.Parse("2018-03-15T10:25:17.7535274");
// Act
var eventGridMessage = EventGridParser.Parse(rawEvent);
// replacedert
replacedert.NotNull(eventGridMessage);
replacedert.NotNull(eventGridMessage.Events);
EventGridEvent eventGridEvent = replacedert.Single(eventGridMessage.Events);
replacedert.Equal(topic, eventGridEvent.Topic);
replacedert.Equal(subject, eventGridEvent.Subject);
replacedert.Equal(eventType, eventGridEvent.EventType);
replacedert.Equal(eventTime, eventGridEvent.EventTime);
replacedert.Equal(id, eventGridEvent.Id);
replacedert.Equal(dataVersion, eventGridEvent.DataVersion);
replacedert.Equal(metadataVersion, eventGridEvent.MetadataVersion);
replacedert.NotNull(eventGridEvent.Data);
var eventPayload = eventGridEvent.GetPayload<StorageBlobCreatedEventData>();
replacedert.NotNull(eventPayload);
replacedert.Equal(api, eventPayload.Api);
replacedert.Equal(clientRequestId, eventPayload.ClientRequestId);
replacedert.Equal(requestId, eventPayload.RequestId);
replacedert.Equal(eTag, eventPayload.ETag);
replacedert.Equal(contentType, eventPayload.ContentType);
replacedert.Equal(contentLength, eventPayload.ContentLength);
replacedert.Equal(blobType, eventPayload.BlobType);
replacedert.Equal(url, eventPayload.Url);
replacedert.Equal(sequencer, eventPayload.Sequencer);
replacedert.NotNull(eventPayload.StorageDiagnostics);
var storageDiagnostics = replacedert.IsType<JObject>(eventPayload.StorageDiagnostics);
replacedert.Equal(batchId, storageDiagnostics["batchId"]);
}
19
Source : AzureIoTHubParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void Parse_ValidDeviceCreatedEvent_ShouldSucceed2()
{
// Arrange
string rawEvent = EventSamples.IoTDeviceCreateEvent;
const string id = "38a23a83-f9c2-493f-e6fb-4b57c7c43d28";
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const string subject = "devices/grid-test-01";
const string eventType = "Microsoft.Devices.DeviceCreated";
const string eventTime = "2018-03-16T05:47:28.1359543Z";
const string stamp = "03/16/2018 05:47:28";
const string dataVersion = "1";
const string metadataVersion = "1";
const string hubName = "savanh-eventgrid-iothub";
const string deviceId = "grid-test-01";
const string etag = "AAAAAAAAAAE=";
const string status = "enabled";
const string connectionState = "Disconnected";
const int cloudToDeviceMessageCount = 0;
const string authenticationType = "sas";
const string primaryThumbprint = "xyz";
const string secondaryThumbprint = "abc";
const int twinVersion = 2;
const int twinPropertyVersion = 1;
// Act
var eventGridMessage = EventGridParser.ParseFromData<IotHubDeviceCreatedEventData>(rawEvent);
// replacedert
replacedert.NotNull(eventGridMessage);
replacedert.NotNull(eventGridMessage.Events);
replacedert.Single(eventGridMessage.Events);
var eventGridEvent = eventGridMessage.Events.Single();
replacedert.Equal(id, eventGridEvent.Id);
replacedert.Equal(topic, eventGridEvent.Topic);
replacedert.Equal(subject, eventGridEvent.Subject);
replacedert.Equal(eventType, eventGridEvent.EventType);
replacedert.Equal(DateTimeOffset.Parse(eventTime), eventGridEvent.EventTime);
replacedert.Equal(dataVersion, eventGridEvent.DataVersion);
replacedert.Equal(metadataVersion, eventGridEvent.MetadataVersion);
var eventGridEventData = eventGridEvent.GetPayload();
replacedert.NotNull(eventGridEventData);
replacedert.Equal(hubName, eventGridEventData.HubName);
replacedert.Equal(deviceId, eventGridEventData.DeviceId);
var twin = eventGridEventData.Twin;
replacedert.NotNull(twin);
replacedert.Equal(deviceId, twin.DeviceId);
replacedert.Equal(etag, twin.Etag);
replacedert.Equal(status, twin.Status);
replacedert.Equal(stamp, twin.StatusUpdateTime);
replacedert.Equal(connectionState, twin.ConnectionState);
replacedert.Equal(stamp, twin.LastActivityTime);
replacedert.Equal(cloudToDeviceMessageCount, twin.CloudToDeviceMessageCount);
replacedert.Equal(authenticationType, twin.AuthenticationType);
replacedert.NotNull(twin.X509Thumbprint);
replacedert.Equal(primaryThumbprint, twin.X509Thumbprint.PrimaryThumbprint);
replacedert.Equal(secondaryThumbprint, twin.X509Thumbprint.SecondaryThumbprint);
replacedert.Equal(twinVersion, twin.Version);
replacedert.NotNull(twin.Properties);
replacedert.NotNull(twin.Properties.Desired);
replacedert.NotNull(twin.Properties.Desired.Metadata);
replacedert.Equal(twinPropertyVersion, twin.Properties.Desired.Version);
replacedert.NotNull(twin.Properties.Desired.Metadata.LastUpdated);
var rawDesiredLastUpdated = twin.Properties.Desired.Metadata.LastUpdated;
replacedert.NotNull(rawDesiredLastUpdated);
replacedert.Equal(stamp, rawDesiredLastUpdated);
replacedert.NotNull(twin.Properties.Reported);
replacedert.NotNull(twin.Properties.Reported.Metadata);
replacedert.Equal(twinPropertyVersion, twin.Properties.Reported.Version);
replacedert.NotNull(twin.Properties.Reported.Metadata.LastUpdated);
var rawReportedLastUpdated = twin.Properties.Reported.Metadata.LastUpdated;
replacedert.NotNull(rawReportedLastUpdated);
replacedert.Equal(stamp, rawDesiredLastUpdated);
}
19
Source : AzureStorageParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void Parse_ValidBlobCreatedEvent_ShouldSucceed()
{
// Arrange
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const string subject = "/blobServices/default/containers/event-container/blobs/finnishjpeg";
const string eventType = "Microsoft.Storage.BlobCreated";
const string id = "5647b67c-b01e-002d-6a47-bc01ac063360";
const string dataVersion = "1";
const string metadataVersion = "1";
const string api = "PutBlockList";
const string clientRequestId = "5c24a322-35c9-4b46-8ef5-245a81af7037";
const string requestId = "5647b67c-b01e-002d-6a47-bc01ac000000";
const string eTag = "0x8D58A5F0C6722F9";
const string contentType = "image/jpeg";
const int contentLength = 29342;
const string blobType = "BlockBlob";
const string url = "https://sample.blob.core.windows.net/event-container/finnish.jpeg";
const string sequencer = "00000000000000000000000000000094000000000017d503";
const string batchId = "69cd1576-e430-4aff-8153-570934a1f6e1";
string rawEvent = EventSamples.BlobCreateEvent;
var eventTime = DateTimeOffset.Parse("2018-03-15T10:25:17.7535274Z");
// Act
var eventGridMessage = EventGridParser.ParseFromData<StorageBlobCreatedEventData>(rawEvent);
// replacedert
replacedert.NotNull(eventGridMessage);
replacedert.NotNull(eventGridMessage.Events);
replacedert.Single(eventGridMessage.Events);
var eventGridEvent = eventGridMessage.Events.Single();
replacedert.Equal(topic, eventGridEvent.Topic);
replacedert.Equal(subject, eventGridEvent.Subject);
replacedert.Equal(eventType, eventGridEvent.EventType);
replacedert.Equal(eventTime, eventGridEvent.EventTime);
replacedert.Equal(id, eventGridEvent.Id);
replacedert.Equal(dataVersion, eventGridEvent.DataVersion);
replacedert.Equal(metadataVersion, eventGridEvent.MetadataVersion);
replacedert.NotNull(eventGridEvent.Data);
StorageBlobCreatedEventData eventPayload = eventGridEvent.GetPayload();
replacedert.NotNull(eventPayload);
replacedert.Equal(api, eventPayload.Api);
replacedert.Equal(clientRequestId, eventPayload.ClientRequestId);
replacedert.Equal(requestId, eventPayload.RequestId);
replacedert.Equal(eTag, eventPayload.ETag);
replacedert.Equal(contentType, eventPayload.ContentType);
replacedert.Equal(contentLength, eventPayload.ContentLength);
replacedert.Equal(blobType, eventPayload.BlobType);
replacedert.Equal(url, eventPayload.Url);
replacedert.Equal(sequencer, eventPayload.Sequencer);
replacedert.NotNull(eventPayload.StorageDiagnostics);
var storageDiagnostics = replacedert.IsType<JObject>(eventPayload.StorageDiagnostics);
replacedert.Equal(batchId, storageDiagnostics["batchId"]);
}
19
Source : EventGridIoTHubParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void Parse_ValidDeviceCreatedEvent_ShouldSucceed()
{
// Arrange
string rawEvent = EventSamples.IoTDeviceCreateEvent;
const string id = "38a23a83-f9c2-493f-e6fb-4b57c7c43d28";
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const string subject = "devices/grid-test-01";
const string eventType = "Microsoft.Devices.DeviceCreated";
const string eventTime = "2018-03-16T05:47:28.1359543Z";
const string stamp = "03/16/2018 05:47:28";
const string dataVersion = "1";
const string metadataVersion = "1";
const string hubName = "savanh-eventgrid-iothub";
const string deviceId = "grid-test-01";
const string etag = "AAAAAAAAAAE=";
const string status = "enabled";
const string connectionState = "Disconnected";
const int cloudToDeviceMessageCount = 0;
const string authenticationType = "sas";
const string primaryThumbprint = "xyz";
const string secondaryThumbprint = "abc";
const int twinVersion = 2;
const int twinPropertyVersion = 1;
// Act
var eventGridMessage = EventGridParser.ParseFromData<IotHubDeviceCreatedEventData>(rawEvent);
// replacedert
replacedert.NotNull(eventGridMessage);
replacedert.NotNull(eventGridMessage.Events);
replacedert.Single(eventGridMessage.Events);
var eventGridEvent = eventGridMessage.Events.Single();
replacedert.Equal(id, eventGridEvent.Id);
replacedert.Equal(topic, eventGridEvent.Topic);
replacedert.Equal(subject, eventGridEvent.Subject);
replacedert.Equal(eventType, eventGridEvent.EventType);
replacedert.Equal(DateTimeOffset.Parse(eventTime), eventGridEvent.EventTime);
replacedert.Equal(dataVersion, eventGridEvent.DataVersion);
replacedert.Equal(metadataVersion, eventGridEvent.MetadataVersion);
var eventGridEventData = eventGridEvent.Data;
replacedert.NotNull(eventGridEventData);
IotHubDeviceCreatedEventData eventPayload = eventGridEvent.GetPayload();
replacedert.NotNull(eventPayload);
replacedert.Equal(hubName, eventPayload.HubName);
replacedert.Equal(deviceId, eventPayload.DeviceId);
var twin = eventPayload.Twin;
replacedert.NotNull(twin);
replacedert.Equal(deviceId, twin.DeviceId);
replacedert.Equal(etag, twin.Etag);
replacedert.Equal(status, twin.Status);
replacedert.Equal(stamp, twin.StatusUpdateTime);
replacedert.Equal(connectionState, twin.ConnectionState);
replacedert.Equal(stamp, twin.LastActivityTime);
replacedert.Equal(cloudToDeviceMessageCount, twin.CloudToDeviceMessageCount);
replacedert.Equal(authenticationType, twin.AuthenticationType);
replacedert.NotNull(twin.X509Thumbprint);
replacedert.Equal(primaryThumbprint, twin.X509Thumbprint.PrimaryThumbprint);
replacedert.Equal(secondaryThumbprint, twin.X509Thumbprint.SecondaryThumbprint);
replacedert.Equal(twinVersion, twin.Version);
replacedert.NotNull(twin.Properties);
replacedert.NotNull(twin.Properties.Desired);
replacedert.NotNull(twin.Properties.Desired.Metadata);
replacedert.Equal(twinPropertyVersion, twin.Properties.Desired.Version);
replacedert.NotNull(twin.Properties.Desired.Metadata.LastUpdated);
var rawDesiredLastUpdated = twin.Properties.Desired.Metadata.LastUpdated;
replacedert.NotNull(rawDesiredLastUpdated);
replacedert.Equal(stamp, rawDesiredLastUpdated);
replacedert.NotNull(twin.Properties.Reported);
replacedert.NotNull(twin.Properties.Reported.Metadata);
replacedert.Equal(twinPropertyVersion, twin.Properties.Reported.Version);
replacedert.NotNull(twin.Properties.Reported.Metadata.LastUpdated);
var rawReportedLastUpdated = twin.Properties.Reported.Metadata.LastUpdated;
replacedert.NotNull(rawReportedLastUpdated);
replacedert.Equal(stamp, rawReportedLastUpdated);
}
19
Source : EventGridParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void Parse_ValidSubscriptionValidationEvent_ShouldSucceed()
{
// Arrange
string rawEvent = EventSamples.SubscriptionValidationEvent;
const string eventId = "2d1781af-3a4c-4d7c-bd0c-e34b19da4e66";
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const string subject = "Sample.Subject";
const string eventType = "Microsoft.EventGrid.SubscriptionValidationEvent";
const string validationCode = "512d38b6-c7b8-40c8-89fe-f46f9e9622b6";
var eventTime = DateTimeOffset.Parse("2017-08-06T22:09:30.740323Z");
// Act
var eventGridBatch = EventGridParser.ParseFromData<SubscriptionValidationEventData>(rawEvent);
// replacedert
replacedert.NotNull(eventGridBatch);
replacedert.NotNull(eventGridBatch.Events);
var eventPayload = replacedert.Single(eventGridBatch.Events);
replacedert.Equal(eventId, eventPayload.Id);
replacedert.Equal(topic, eventPayload.Topic);
replacedert.Equal(subject, eventPayload.Subject);
replacedert.Equal(eventType, eventPayload.EventType);
replacedert.Equal(eventTime, eventPayload.EventTime);
replacedert.NotNull(eventPayload.Data);
replacedert.Equal(validationCode, eventPayload.GetPayload()?.ValidationCode);
}
19
Source : EventParsingTests.cs
with MIT License
from arcus-azure
with MIT License
from arcus-azure
[Fact]
public void ParseImplicit_ValidBlobCreatedEvent_ShouldSucceed()
{
// Arrange
const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const string subject = "/blobServices/default/containers/event-container/blobs/finnishjpeg";
const string eventType = "Microsoft.Storage.BlobCreated";
const string id = "5647b67c-b01e-002d-6a47-bc01ac063360";
const string dataVersion = "1";
const string metadataVersion = "1";
const string api = "PutBlockList";
const string clientRequestId = "5c24a322-35c9-4b46-8ef5-245a81af7037";
const string requestId = "5647b67c-b01e-002d-6a47-bc01ac000000";
const string eTag = "0x8D58A5F0C6722F9";
const string contentType = "image/jpeg";
const int contentLength = 29342;
const string blobType = "BlockBlob";
const string url = "https://sample.blob.core.windows.net/event-container/finnish.jpeg";
const string sequencer = "00000000000000000000000000000094000000000017d503";
const string batchId = "69cd1576-e430-4aff-8153-570934a1f6e1";
string rawEvent = EventSamples.BlobCreateEvent;
var eventTime = DateTimeOffset.Parse("2018-03-15T10:25:17.7535274Z");
// Act
EventBatch<Event> eventGridMessage = EventParser.Parse(rawEvent);
// replacedert
replacedert.NotNull(eventGridMessage);
replacedert.NotNull(eventGridMessage.Events);
Event eventGridEvent = replacedert.Single(eventGridMessage.Events);
replacedert.NotNull(eventGridEvent);
replacedert.Equal(topic, eventGridEvent.Topic);
replacedert.Equal(subject, eventGridEvent.Subject);
replacedert.Equal(eventType, eventGridEvent.EventType);
replacedert.Equal(eventTime, eventGridEvent.EventTime);
replacedert.Equal(id, eventGridEvent.Id);
replacedert.Equal(dataVersion, eventGridEvent.DataVersion);
replacedert.Equal(metadataVersion, eventGridEvent.MetadataVersion);
var eventPayload = eventGridEvent.GetPayload<StorageBlobCreatedEventData>();
replacedert.NotNull(eventPayload);
replacedert.Equal(api, eventPayload.Api);
replacedert.Equal(clientRequestId, eventPayload.ClientRequestId);
replacedert.Equal(requestId, eventPayload.RequestId);
replacedert.Equal(eTag, eventPayload.ETag);
replacedert.Equal(contentType, eventPayload.ContentType);
replacedert.Equal(contentLength, eventPayload.ContentLength);
replacedert.Equal(blobType, eventPayload.BlobType);
replacedert.Equal(url, eventPayload.Url);
replacedert.Equal(sequencer, eventPayload.Sequencer);
replacedert.NotNull(eventPayload.StorageDiagnostics);
var storageDiagnostics = replacedert.IsType<JObject>(eventPayload.StorageDiagnostics);
replacedert.Equal(batchId, storageDiagnostics["batchId"]);
}
19
Source : HttpResponseParserTest.cs
with Apache License 2.0
from Asesjix
with Apache License 2.0
from Asesjix
[Fact]
public async Task ParseJsonContentAsync_Success_TestAsync()
{
var httpResponse = CreateTestResponse();
var ticket = await new HttpResponseParser()
.UseHttpResponse(httpResponse)
.ParseJsonContentAsync<Ticket>();
replacedert.Equal(1, ticket.Id);
replacedert.Equal(1, ticket.GroupId);
replacedert.Equal(2, ticket.PriorityId);
replacedert.Equal(1, ticket.StateId);
replacedert.Equal(1, ticket.OrganizationId);
replacedert.Equal("96001", ticket.Number);
replacedert.Equal("Welcome to Zammad!", ticket.replacedle);
replacedert.Equal(1, ticket.OwnerId);
replacedert.Equal(2, ticket.CustomerId);
replacedert.Null(ticket.Note);
replacedert.Null(ticket.FirstResponseAt);
replacedert.Null(ticket.FirstResponseEscalationAt);
replacedert.Null(ticket.FirstResponseInMin);
replacedert.Null(ticket.FirstResponseDiffInMin);
replacedert.Null(ticket.CloseAt);
replacedert.Null(ticket.CloseEscalationAt);
replacedert.Null(ticket.CloseInMin);
replacedert.Null(ticket.CloseDiffInMin);
replacedert.Null(ticket.UpdateEscalationAt);
replacedert.Null(ticket.UpdateInMin);
replacedert.Null(ticket.UpdateDiffInMin);
replacedert.Equal(DateTimeOffset.Parse("2017-09-25T14:50:50.946Z"), ticket.LastContactAt);
replacedert.Null(ticket.LastContactAgentAt);
replacedert.Equal(DateTimeOffset.Parse("2017-09-25T14:50:50.946Z"), ticket.LastContactCustomerAt);
replacedert.Null(ticket.LastOwnerUpdateAt);
replacedert.Equal(5, ticket.CreateArticleTypeId);
replacedert.Equal(2, ticket.CreateArticleSenderId);
replacedert.Equal(1, ticket.ArticleCount);
replacedert.Null(ticket.EscalationAt);
replacedert.Null(ticket.PendingTime);
replacedert.Null(ticket.Type);
replacedert.Null(ticket.TimeUnit);
replacedert.Equal(new Dictionary<string, object>(), ticket.Preferences);
replacedert.Equal(3, ticket.UpdatedById);
replacedert.Equal(2, ticket.CreatedById);
replacedert.Equal(DateTimeOffset.Parse("2017-09-25T14:50:50.910Z"), ticket.CreatedAt);
replacedert.Equal(DateTimeOffset.Parse("2017-09-30T14:47:55.177Z"), ticket.UpdatedAt);
}
19
Source : YotsubaApiTests.cs
with MIT License
from bbepis
with MIT License
from bbepis
[Test]
public async Task GetThread_SetsNotModifiedSinceHeader()
{
var mockHandler = CreateMockClientHandler(HttpStatusCode.NotModified, null);
var client = new HttpClient(mockHandler.Object);
var baseDateTimeOffset = DateTimeOffset.Parse("12/3/2007 12:00:00 AM -08:00");
await YotsubaApi.GetThread("a", 1234, client, baseDateTimeOffset);
mockHandler.Protected().Verify(
"SendAsync",
Times.Exactly(1),
ItExpr.Is<HttpRequestMessage>(req =>
req.Headers.IfModifiedSince == baseDateTimeOffset
),
ItExpr.IsAny<CancellationToken>()
);
}
19
Source : YotsubaApiTests.cs
with MIT License
from bbepis
with MIT License
from bbepis
[Test]
public async Task GetBoard_SetsNotModifiedSinceHeader()
{
var mockHandler = CreateMockClientHandler(HttpStatusCode.NotModified, null);
var client = new HttpClient(mockHandler.Object);
var baseDateTimeOffset = DateTimeOffset.Parse("12/3/2007 12:00:00 AM -08:00");
await YotsubaApi.GetBoard("a", client, baseDateTimeOffset);
mockHandler.Protected().Verify(
"SendAsync",
Times.Exactly(1),
ItExpr.Is<HttpRequestMessage>(req =>
req.Headers.IfModifiedSince == baseDateTimeOffset
),
ItExpr.IsAny<CancellationToken>()
);
}
19
Source : YotsubaApiTests.cs
with MIT License
from bbepis
with MIT License
from bbepis
[Test]
public async Task GetArchive_SetsNotModifiedSinceHeader()
{
var mockHandler = CreateMockClientHandler(HttpStatusCode.NotModified, null);
var client = new HttpClient(mockHandler.Object);
var baseDateTimeOffset = DateTimeOffset.Parse("12/3/2007 12:00:00 AM -08:00");
await YotsubaApi.GetArchive("a", client, baseDateTimeOffset);
mockHandler.Protected().Verify(
"SendAsync",
Times.Exactly(1),
ItExpr.Is<HttpRequestMessage>(req =>
req.Headers.IfModifiedSince == baseDateTimeOffset
),
ItExpr.IsAny<CancellationToken>()
);
}
19
Source : JsonClientTests.cs
with MIT License
from Beffyman
with MIT License
from Beffyman
[Fact(Timeout = Constants.TEST_TIMEOUT)]
public void DateTimeOffsetRouteTests()
{
using (var endpoint = new JsonServerInfo())
{
var valuesClient = endpoint.Provider.GetService<IValuesClient>();
var date = DateTimeOffset.UtcNow;
var expected = DateTimeOffset.Parse(date.ToString("s", System.Globalization.CultureInfo.InvariantCulture));
DateTimeOffset result = valuesClient.CheckDateTimeOffset(date, cancellationToken: endpoint.TimeoutToken);
replacedert.Equal(expected, result);
DateTimeOffset? nullableResult = valuesClient.CheckDateTimeOffsetNullable(date, cancellationToken: endpoint.TimeoutToken);
replacedert.Equal(expected, nullableResult);
}
}
19
Source : NodeService.cs
with GNU General Public License v3.0
from BlazorWorld
with GNU General Public License v3.0
from BlazorWorld
private double Hot(int upVotes, int downVotes, string createdDate)
{
var score = upVotes - downVotes;
var order = Math.Log10(Math.Max(Math.Abs(score), 1));
var sign = 0;
if (score > 0) sign = 1;
if (score < 0) sign = -1;
TimeSpan t = DateTimeOffset.Parse(createdDate) - new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
int secondsSinceEpoch = (int)t.TotalSeconds;
var hot = Math.Round(order + (sign * secondsSinceEpoch) / 45000, 7);
return hot;
}
19
Source : ServerMomentService.cs
with GNU General Public License v3.0
from BlazorWorld
with GNU General Public License v3.0
from BlazorWorld
public async Task<string> FromNowAsync(string dateString)
{
return DateTimeOffset.Parse(dateString).ToLocalTime().ToString("MMMM dd, yyyy");
}
19
Source : Item.cs
with GNU General Public License v3.0
from BlazorWorld
with GNU General Public License v3.0
from BlazorWorld
public string FormattedCreatedDate()
{
var date = DateTimeOffset.Parse(CreatedDate);
return date.ToLocalTime().ToString();
}
19
Source : Item.cs
with GNU General Public License v3.0
from BlazorWorld
with GNU General Public License v3.0
from BlazorWorld
public string FormattedUpdatedDate()
{
var date = DateTimeOffset.Parse(LastUpdatedDate);
return date.ToString();
}
19
Source : RedisTimeProviderTest.cs
with Apache License 2.0
from bosima
with Apache License 2.0
from bosima
[DataTestMethod]
public void TestGetCurrentUtcMilliseconds()
{
var currentTs = GetTimeProvider().GetCurrentUtcMilliseconds();
replacedert.AreEqual(true, currentTs > DateTimeOffset.Parse("2021-1-1").ToUnixTimeMilliseconds());
}
19
Source : RedisTimeProviderTest.cs
with Apache License 2.0
from bosima
with Apache License 2.0
from bosima
[DataTestMethod]
public async Task TestGetCurrentUtcMillisecondsAsync()
{
var currentTs = await GetTimeProvider().GetCurrentUtcMillisecondsAsync();
replacedert.AreEqual(true, currentTs > DateTimeOffset.Parse("2021-1-1").ToUnixTimeMilliseconds());
}
19
Source : AlgorithmStartTimeTest.cs
with Apache License 2.0
from bosima
with Apache License 2.0
from bosima
[DataTestMethod]
public void TestToNaturalPeriodBeignTime()
{
DateTimeOffset startTime = DateTimeOffset.Parse("2021-12-21 21:21:21.211");
var startTime1 = AlgorithmStartTime.ToNaturalPeriodBeignTime(startTime, TimeSpan.Parse("1"));
replacedert.AreEqual("2021-12-21 00:00:00.000", startTime1.ToString("yyyy-MM-dd HH:mm:ss.fff"));
var startTime2 = AlgorithmStartTime.ToNaturalPeriodBeignTime(startTime, TimeSpan.Parse("0.01:00:00"));
replacedert.AreEqual("2021-12-21 21:00:00.000", startTime2.ToString("yyyy-MM-dd HH:mm:ss.fff"));
var startTime3 = AlgorithmStartTime.ToNaturalPeriodBeignTime(startTime, TimeSpan.Parse("0.00:01:00"));
replacedert.AreEqual("2021-12-21 21:21:00.000", startTime3.ToString("yyyy-MM-dd HH:mm:ss.fff"));
var startTime4 = AlgorithmStartTime.ToNaturalPeriodBeignTime(startTime, TimeSpan.Parse("0.00:00:01"));
replacedert.AreEqual("2021-12-21 21:21:21.000", startTime4.ToString("yyyy-MM-dd HH:mm:ss.fff"));
}
19
Source : AlgorithmStartTimeTest.cs
with Apache License 2.0
from bosima
with Apache License 2.0
from bosima
[DataTestMethod]
public void TestToSpecifiedTypeTime()
{
DateTimeOffset startTime = DateTimeOffset.Parse("2021-12-21 21:21:21.211");
long startTimeTs = startTime.ToUnixTimeMilliseconds();
var startTime1 = AlgorithmStartTime.ToSpecifiedTypeTime(startTime, TimeSpan.Parse("1"), StartTimeType.FromCurrent);
replacedert.AreEqual("2021-12-21 21:21:21.211", startTime1.ToString("yyyy-MM-dd HH:mm:ss.fff"));
var startTime2 = AlgorithmStartTime.ToSpecifiedTypeTime(startTime, TimeSpan.Parse("1"), StartTimeType.FromNaturalPeriodBeign);
replacedert.AreEqual("2021-12-21 00:00:00.000", startTime2.ToString("yyyy-MM-dd HH:mm:ss.fff"));
var startTime3 = AlgorithmStartTime.ToSpecifiedTypeTime(startTimeTs, TimeSpan.Parse("1"), StartTimeType.FromCurrent);
replacedert.AreEqual(startTimeTs, startTime3);
var startTime4 = AlgorithmStartTime.ToSpecifiedTypeTime(startTimeTs, TimeSpan.Parse("1"), StartTimeType.FromNaturalPeriodBeign);
replacedert.AreEqual(1640044800000, startTime4);
}
19
Source : SimpleGraphClient.cs
with MIT License
from BotBuilderCommunity
with MIT License
from BotBuilderCommunity
public async Task<Beta.PlannerTask> CreatePlannerTaskAsync(string planId, string subject, string dueDate, string startTime, string userId)
{
var graphClient = GetAuthenticatedClient();
var replacedignments = new Beta.Plannerreplacedignments();
replacedignments.Addreplacedignee(userId);
var plannerTask = new Beta.PlannerTask
{
DueDateTime = DateTimeOffset.Parse(dueDate),
StartDateTime = DateTimeOffset.Parse(startTime),
replacedle = subject,
PlanId = planId,
replacedignments = replacedignments
//BucketId = bucketId
};
var plans = await graphClient.Planner.Tasks.Request().AddAsync(plannerTask);
return plans;
}
19
Source : FilterExpressionBuilder.cs
with MIT License
from bradwestness
with MIT License
from bradwestness
private static Expression GetFilterExpression<T>(FilterOperator filterOperator, ParameterExpression param, string filterValue, string fieldName)
{
MemberExpression member = Expression.Property(param, fieldName);
ConstantExpression constant;
if (member.Type == typeof(bool) || member.Type == typeof(bool?))
{
constant = Expression.Constant(bool.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(byte) || member.Type == typeof(byte?))
{
constant = Expression.Constant(byte.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(char) || member.Type == typeof(char?))
{
constant = Expression.Constant(char.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(DateTime) || member.Type == typeof(DateTime?))
{
constant = Expression.Constant(DateTime.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(DateTimeOffset) || member.Type == typeof(DateTimeOffset?))
{
constant = Expression.Constant(DateTimeOffset.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(decimal) || member.Type == typeof(decimal?))
{
constant = Expression.Constant(decimal.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(double) || member.Type == typeof(double?))
{
constant = Expression.Constant(double.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(float) || member.Type == typeof(float?))
{
constant = Expression.Constant(float.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(Guid) || member.Type == typeof(Guid?))
{
constant = Expression.Constant(Guid.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(int) || member.Type == typeof(int?))
{
constant = Expression.Constant(int.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(long) || member.Type == typeof(long?))
{
constant = Expression.Constant(long.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(sbyte) || member.Type == typeof(sbyte?))
{
constant = Expression.Constant(sbyte.Parse(filterValue), member.Type);
}
else if (member.Type == typeof(short) || member.Type == typeof(short?))
{
constant = Expression.Constant(short.Parse(filterValue), member.Type);
}
else
{
constant = Expression.Constant(filterValue, member.Type);
}
Expression expression;
switch (filterOperator)
{
case FilterOperator.GreaterThanOrEqual:
expression = Expression.GreaterThanOrEqual(member, constant);
break;
case FilterOperator.LessThanOrEqual:
expression = Expression.LessThanOrEqual(member, constant);
break;
case FilterOperator.LessThan:
expression = Expression.LessThan(member, constant);
break;
case FilterOperator.GreaterThan:
expression = Expression.GreaterThan(member, constant);
break;
case FilterOperator.Equal:
expression = Expression.Equal(member, constant);
break;
case FilterOperator.NotEqual:
expression = Expression.NotEqual(member, constant);
break;
case FilterOperator.Contains:
expression = Expression.Call(member, _containsMethod, constant);
break;
case FilterOperator.DoesNotContain:
expression = Expression.Not(Expression.Call(member, _containsMethod, constant));
break;
case FilterOperator.EndsWith:
expression = Expression.Call(member, _endsWithMethod, constant);
break;
case FilterOperator.StartsWith:
expression = Expression.Call(member, _startsWithMethod, constant);
break;
default:
throw new ArgumentException($"Invalid filter operator: {filterOperator}.", nameof(filterOperator));
}
return expression;
}
19
Source : WeChatPaymentNoticeResult.cs
with MIT License
from bxjg1987
with MIT License
from bxjg1987
public async Task<WeChatPaymentNoticeResult> LoadAsync(Stream stream, CancellationToken cancellation = default)
{
var xd = await XDoreplacedent.LoadAsync(stream, LoadOptions.None, cancellation);
var c = xd.Root;
var p = new WeChatPaymentNoticeResult();
p.return_code = Enum.Parse<return_code>((string)c.Element("return_code"));
p.return_msg = (string)c.Element("return_msg");
if (p.return_code != return_code.SUCCESS)
return p;
p.appid = (string)c.Element("appid");
p.mch_id = (string)c.Element("mch_id");
p.device_info = (string)c.Element("device_info");
p.nonce_str = (string)c.Element("nonce_str");
p.sign = (string)c.Element("sign");
var sign_type = (string)c.Element("sign_type");
if (!string.IsNullOrWhiteSpace(sign_type))
p.sign_type = Enum.Parse<sign_type>(sign_type);
p.result_code = Enum.Parse<result_code>((string)c.Element("result_code"));
p.err_code = (string)c.Element("err_code");
p.err_code_des = (string)c.Element("err_code_des");
if (p.result_code != result_code.SUCCESS)
return p;
p.openid = (string)c.Element("openid");
p.is_subscribe = (bool)c.Element("is_subscribe");
p.trade_type = Enum.Parse<trade_type>((string)c.Element("trade_type"));
p.bank_type = (string)c.Element("bank_type");
p.total_fee = (int)c.Element("total_fee") / 100m;
var settlement_total_fee = (string)c.Element("settlement_total_fee");
if (!string.IsNullOrWhiteSpace(settlement_total_fee))
p.settlement_total_fee = Convert.ToDecimal(settlement_total_fee) / 100;
var fee_type = (string)c.Element("fee_type");
if (!string.IsNullOrWhiteSpace(fee_type))
p.fee_type = Enum.Parse<fee_type>((string)c.Element("fee_type"));
#region 现金
var cash_fee = (string)c.Element("cash_fee");
if (!string.IsNullOrWhiteSpace(cash_fee))
p.cash_fee = Convert.ToDecimal(cash_fee) / 100;
var cash_fee_type = (string)c.Element("cash_fee_type");
if (!string.IsNullOrWhiteSpace(cash_fee_type))
p.cash_fee_type = Enum.Parse<fee_type>((string)c.Element("cash_fee_type"));
#endregion
#region 代金券
var coupon_fee = (string)c.Element("coupon_fee");
if (!string.IsNullOrWhiteSpace(coupon_fee))
p.coupon_fee = Convert.ToDecimal(coupon_fee) / 100;
var coupon_count = (string)c.Element("coupon_count");
if (!string.IsNullOrWhiteSpace(coupon_count))
p.coupon_count = Convert.ToInt32(coupon_count);
var coupon_type_0 = (string)c.Element("coupon_type_0");
if (!string.IsNullOrWhiteSpace(coupon_type_0))
{
p.coupon_type_0 = Enum.Parse<coupon_type>((string)c.Element("coupon_type_0"));
p.coupon_fee_0 = Convert.ToDecimal(c.Element("coupon_fee_0")) / 100;
}
var coupon_type_1 = (string)c.Element("coupon_type_1");
if (!string.IsNullOrWhiteSpace(coupon_type_1))
{
p.coupon_type_1 = Enum.Parse<coupon_type>((string)c.Element("coupon_type_1"));
p.coupon_fee_1 = Convert.ToDecimal(c.Element("coupon_fee_1")) / 100;
}
var coupon_type_2 = (string)c.Element("coupon_type_2");
if (!string.IsNullOrWhiteSpace(coupon_type_2))
{
p.coupon_type_2 = Enum.Parse<coupon_type>((string)c.Element("coupon_type_2"));
p.coupon_fee_2 = Convert.ToDecimal(c.Element("coupon_fee_2")) / 100;
}
var coupon_type_3 = (string)c.Element("coupon_type_3");
if (!string.IsNullOrWhiteSpace(coupon_type_3))
{
p.coupon_type_3 = Enum.Parse<coupon_type>((string)c.Element("coupon_type_3"));
p.coupon_fee_3 = Convert.ToDecimal(c.Element("coupon_fee_3")) / 100;
}
var coupon_type_4 = (string)c.Element("coupon_type_4");
if (!string.IsNullOrWhiteSpace(coupon_type_4))
{
p.coupon_type_4 = Enum.Parse<coupon_type>((string)c.Element("coupon_type_4"));
p.coupon_fee_4 = Convert.ToDecimal(c.Element("coupon_fee_4")) / 100;
}
p.coupon_id_0 = (string)c.Element("coupon_id_0");
p.coupon_id_1 = (string)c.Element("coupon_id_1");
p.coupon_id_2 = (string)c.Element("coupon_id_2");
p.coupon_id_3 = (string)c.Element("coupon_id_3");
p.coupon_id_4 = (string)c.Element("coupon_id_4");
#endregion
p.transaction_id = (string)c.Element("transaction_id");
p.out_trade_no = (string)c.Element("out_trade_no");
p.attach = (string)c.Element("attach");
p.time_end = DateTimeOffset.Parse((string)c.Element("time_end"));
if (!securet.CheckSign(p))
throw new InvalidCastException("微信小程序支付 > 支付结果通知 > 微信提交过来的数据 > sign校验失败!");
return p;
}
19
Source : SettingsService.cs
with MIT License
from CalciumFramework
with MIT License
from CalciumFramework
object GetSettingFromStore(string key, bool xmlConvertible,
Type settingType, object defaultValue, out bool returningDefaultValue)
{
returningDefaultValue = false;
string cacheKey = key;
if (cache.TryGetValue(cacheKey, out object cacheResult))
{
return cacheResult;
}
object entry = null;
bool retrievedExisting = localStore.Status == SettingsStoreStatus.Ready && localStore.TryGetValue(key, settingType, out entry);
/* Don't use |= here because doing so prevents short circuiting from occurring. */
retrievedExisting = retrievedExisting || roamingStore != null && roamingStore.Status == SettingsStoreStatus.Ready && roamingStore.TryGetValue(key, settingType, out entry);
retrievedExisting = retrievedExisting || transientStore != null && transientStore.Status == SettingsStoreStatus.Ready && transientStore.TryGetValue(key, settingType, out entry);
if (retrievedExisting)
{
if (xmlConvertible && entry != null)
{
Type concreteType;
if (settingType.IsInterface())
{
if (defaultValue == null)
{
throw new SettingsException($"Unable to retrieve IXmlConvertible setting object specified by interface type {settingType.FullName}. "
+ "Retrieve this value using a concrete implementation type.");
}
concreteType = defaultValue.GetType();
}
else
{
concreteType = settingType;
}
if (TryConvertFromXml(concreteType, entry, out object objectConvertedFromXml))
{
return objectConvertedFromXml;
}
}
/* Android and perhaps other platforms don't have built in support for complex types.
* In the case where the entry is stored as a string but the setting type is not a string,
* we attempt to convert the value.
* Here we deal with dates and resort to a type converter if all else fails. */
Type entryType = entry?.GetType();
if (entry != null && entryType != settingType
&& settingType != typeof(string) && entryType == typeof(string))
{
string entryString = (string)entry;
try
{
var stringEntry = (string)entry;
if (settingType == typeof(DateTime))
{
DateTime d = DateTime.Parse(stringEntry);
entry = d;
}
else if (settingType == typeof(DateTime?))
{
DateTime? d = null;
if (!string.IsNullOrEmpty(stringEntry))
{
d = DateTime.Parse(stringEntry);
}
entry = d;
}
else if (settingType == typeof(DateTimeOffset))
{
DateTimeOffset d = DateTimeOffset.Parse(stringEntry);
entry = d;
}
else if (settingType == typeof(DateTimeOffset?))
{
DateTimeOffset? d = null;
if (!string.IsNullOrEmpty(stringEntry))
{
d = DateTimeOffset.Parse(stringEntry);
}
entry = d;
}
else if (entryString.StartsWith(SerializationContants.Base64EncodingPrefix))
{
int lengthOfPrefix = SerializationContants.Base64EncodingPrefix.Length;
var dataPart = entryString.Substring(lengthOfPrefix, entryString.Length - lengthOfPrefix);
entry = Convert.FromBase64String(dataPart);
}
else
{
// var converter = new FromStringConverter(settingType);
// var convertedValue = converter.ConvertFrom(entry);
// entry = convertedValue;
entry = entryString;
}
}
catch (Exception ex)
{
string message = $"Unable to parse setting that is of type {settingType} but is stored as a string";
throw new SettingsException(message, ex);
}
}
/* Dictionaries and other complex types can be difficult to serialize.
* In some cases the SilverlightSerializer is used to serializer such objects.
*/
entry = InflateEntry(settingType, entry);
cache[cacheKey] = entry;
return entry;
}
returningDefaultValue = true;
return defaultValue;
}
19
Source : OrclPower.cs
with GNU General Public License v3.0
from ClayLipscomb
with GNU General Public License v3.0
from ClayLipscomb
private static T ReadResultRow<T>(OracleDataReader reader, List<ColumnMapping> mappings) where T : new() {
Object value;
// create a DTO instance with properties/fields set from respective columns based on mappings
T obj = new T(); // create new instance
foreach (ColumnMapping m in mappings) {
if (reader.IsDBNull(reader.GetOrdinal(m.Column.ColumnName)))
value = null;
else if (m.IsRoundOracleDecimalToCSharpDecimal) // an OracleDecimal (sig dig 38) has to be rounded to fit in C# Decimal (sig dig 28)
value = (Decimal?)OracleDecimal.SetPrecision(reader.GetOracleDecimal(reader.GetOrdinal(m.Column.ColumnName)), 28);
else if (m.MemberUnderlyingType.Namespace.Equals("Oracle.ManagedDataAccess.Types"))
value = reader.GetOracleValue(reader.GetOrdinal(m.Column.ColumnName));
else if (m.MemberUnderlyingType.Equals(typeof(DateTimeOffset)))
value = DateTimeOffset.Parse(reader.GetValue(reader.GetOrdinal(m.Column.ColumnName)).ToString());
else
value = reader.GetValue(reader.GetOrdinal(m.Column.ColumnName));
SetObjectMember(obj, m.Member, value);
}
return obj;
}
19
Source : DocsTestBase.cs
with GNU Lesser General Public License v3.0
from cnAbp
with GNU Lesser General Public License v3.0
from cnAbp
protected override void AfterAddApplication(IServiceCollection services)
{
var repositoryManager = Subsreplacedute.For<IGithubRepositoryManager>();
repositoryManager.GetFileRawStringContentAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
.Returns("stringContent");
repositoryManager.GetFileRawByteArrayContentAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
.Returns(new byte[] { 0x01, 0x02, 0x03 });
repositoryManager.GetReleasesAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
.Returns(new List<Release>
{
new Release("https://api.github.com/repos/abpframework/abp/releases/16293679",
"https://github.com/abpframework/abp/releases/tag/0.15.0",
"https://api.github.com/repos/abpframework/abp/releases/16293679/replacedets",
"https://uploads.github.com/repos/abpframework/abp/releases/16293679/replacedets{?name,label}",
16293679,
"0.15.0",
"master",
"0.15.0",
"0.15.0 already release",
false,
false,
DateTimeOffset.Parse("2019-03-22T18:43:58Z"),
DateTimeOffset.Parse("2019-03-22T19:44:25Z"),
null,
"https://api.github.com/repos/abpframework/abp/tarball/0.15.0",
"https://api.github.com/repos/abpframework/abp/zipball/0.15.0",
null)
});
services.AddSingleton(repositoryManager);
}
19
Source : IdentityUserStore_Tests.cs
with GNU Lesser General Public License v3.0
from cnAbp
with GNU Lesser General Public License v3.0
from cnAbp
[Fact]
public async Task SetLockoutEndDateAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash"));
user.ShouldNotBeNull();
await _idenreplacedyUserStore.SetLockoutEndDateAsync(user, DateTimeOffset.Parse("01/01/2019"));
user.LockoutEnd.ShouldBe(DateTimeOffset.Parse("01/01/2019"));
}
19
Source : TestApiTestAllFieldTypeClientModelMapper.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public void MapClientRequestToResponse()
{
var mapper = new ApiTestAllFieldTypeModelMapper();
var model = new ApiTestAllFieldTypeClientRequestModel();
model.SetProperties(1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
ApiTestAllFieldTypeClientResponseModel response = mapper.MapClientRequestToResponse(1, model);
response.Should().NotBeNull();
response.FieldBigInt.Should().Be(1);
response.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldBit.Should().Be(true);
response.FieldChar.Should().Be("A");
response.FieldDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
response.FieldDecimal.Should().Be(1m);
response.FieldFloat.Should().Be(1);
response.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldMoney.Should().Be(1m);
response.FieldNChar.Should().Be("A");
response.FieldNText.Should().Be("A");
response.FieldNumeric.Should().Be(1m);
response.FieldNVarchar.Should().Be("A");
response.FieldReal.Should().Be(1m);
response.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldSmallInt.Should().Be(1);
response.FieldSmallMoney.Should().Be(1m);
response.FieldText.Should().Be("A");
response.FieldTime.Should().Be(TimeSpan.Parse("01:00:00"));
response.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldTinyInt.Should().Be(1);
response.FieldUniqueIdentifier.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
response.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldVarchar.Should().Be("A");
response.FieldXML.Should().Be("A");
}
19
Source : TestApiTestAllFieldTypeClientModelMapper.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public void MapClientResponseToRequest()
{
var mapper = new ApiTestAllFieldTypeModelMapper();
var model = new ApiTestAllFieldTypeClientResponseModel();
model.SetProperties(1, 1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
ApiTestAllFieldTypeClientRequestModel response = mapper.MapClientResponseToRequest(model);
response.Should().NotBeNull();
response.FieldBigInt.Should().Be(1);
response.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldBit.Should().Be(true);
response.FieldChar.Should().Be("A");
response.FieldDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
response.FieldDecimal.Should().Be(1m);
response.FieldFloat.Should().Be(1);
response.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldMoney.Should().Be(1m);
response.FieldNChar.Should().Be("A");
response.FieldNText.Should().Be("A");
response.FieldNumeric.Should().Be(1m);
response.FieldNVarchar.Should().Be("A");
response.FieldReal.Should().Be(1m);
response.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldSmallInt.Should().Be(1);
response.FieldSmallMoney.Should().Be(1m);
response.FieldText.Should().Be("A");
response.FieldTime.Should().Be(TimeSpan.Parse("01:00:00"));
response.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldTinyInt.Should().Be(1);
response.FieldUniqueIdentifier.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
response.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldVarchar.Should().Be("A");
response.FieldXML.Should().Be("A");
}
19
Source : TestApiTestAllFieldTypesNullableClientModelMapper.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public void MapClientRequestToResponse()
{
var mapper = new ApiTestAllFieldTypesNullableModelMapper();
var model = new ApiTestAllFieldTypesNullableClientRequestModel();
model.SetProperties(1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
ApiTestAllFieldTypesNullableClientResponseModel response = mapper.MapClientRequestToResponse(1, model);
response.Should().NotBeNull();
response.FieldBigInt.Should().Be(1);
response.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldBit.Should().Be(true);
response.FieldChar.Should().Be("A");
response.FieldDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
response.FieldDecimal.Should().Be(1m);
response.FieldFloat.Should().Be(1);
response.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldMoney.Should().Be(1m);
response.FieldNChar.Should().Be("A");
response.FieldNText.Should().Be("A");
response.FieldNumeric.Should().Be(1m);
response.FieldNVarchar.Should().Be("A");
response.FieldReal.Should().Be(1m);
response.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldSmallInt.Should().Be(1);
response.FieldSmallMoney.Should().Be(1m);
response.FieldText.Should().Be("A");
response.FieldTime.Should().Be(TimeSpan.Parse("01:00:00"));
response.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldTinyInt.Should().Be(1);
response.FieldUniqueIdentifier.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
response.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldVarchar.Should().Be("A");
response.FieldXML.Should().Be("A");
}
19
Source : TestApiTestAllFieldTypesNullableClientModelMapper.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public void MapClientResponseToRequest()
{
var mapper = new ApiTestAllFieldTypesNullableModelMapper();
var model = new ApiTestAllFieldTypesNullableClientResponseModel();
model.SetProperties(1, 1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
ApiTestAllFieldTypesNullableClientRequestModel response = mapper.MapClientResponseToRequest(model);
response.Should().NotBeNull();
response.FieldBigInt.Should().Be(1);
response.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldBit.Should().Be(true);
response.FieldChar.Should().Be("A");
response.FieldDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
response.FieldDecimal.Should().Be(1m);
response.FieldFloat.Should().Be(1);
response.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldMoney.Should().Be(1m);
response.FieldNChar.Should().Be("A");
response.FieldNText.Should().Be("A");
response.FieldNumeric.Should().Be(1m);
response.FieldNVarchar.Should().Be("A");
response.FieldReal.Should().Be(1m);
response.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldSmallInt.Should().Be(1);
response.FieldSmallMoney.Should().Be(1m);
response.FieldText.Should().Be("A");
response.FieldTime.Should().Be(TimeSpan.Parse("01:00:00"));
response.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldTinyInt.Should().Be(1);
response.FieldUniqueIdentifier.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
response.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldVarchar.Should().Be("A");
response.FieldXML.Should().Be("A");
}
19
Source : AbstractIntegrationTestMigration.cs
with MIT License
from codenesium
with MIT License
from codenesium
public virtual async Task Migrate()
{
var columnSameAsFKTableItem1 = new ColumnSameAsFKTable();
columnSameAsFKTableItem1.SetProperties(1, 1, 1);
this.Context.ColumnSameAsFKTables.Add(columnSameAsFKTableItem1);
var includedColumnTesreplacedem1 = new IncludedColumnTest();
includedColumnTesreplacedem1.SetProperties(1, "A", "A");
this.Context.IncludedColumnTests.Add(includedColumnTesreplacedem1);
var personItem1 = new Person();
personItem1.SetProperties(1, "A");
this.Context.People.Add(personItem1);
var rowVersionCheckItem1 = new RowVersionCheck();
rowVersionCheckItem1.SetProperties(1, "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
this.Context.RowVersionChecks.Add(rowVersionCheckItem1);
var selfReferenceItem1 = new SelfReference();
selfReferenceItem1.SetProperties(1, 1, 1);
this.Context.SelfReferences.Add(selfReferenceItem1);
var tableItem1 = new Table();
tableItem1.SetProperties(1, "A");
this.Context.Tables.Add(tableItem1);
var testAllFieldTypeItem1 = new TestAllFieldType();
testAllFieldTypeItem1.SetProperties(1, 1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
this.Context.TestAllFieldTypes.Add(testAllFieldTypeItem1);
var testAllFieldTypesNullableItem1 = new TestAllFieldTypesNullable();
testAllFieldTypesNullableItem1.SetProperties(1, 1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
this.Context.TestAllFieldTypesNullables.Add(testAllFieldTypesNullableItem1);
var timestampCheckItem1 = new TimestampCheck();
timestampCheckItem1.SetProperties(1, "A", BitConverter.GetBytes(1));
this.Context.TimestampChecks.Add(timestampCheckItem1);
var vPersonItem1 = new VPerson();
vPersonItem1.SetProperties(1, "A");
this.Context.VPersons.Add(vPersonItem1);
await this.Context.SaveChangesAsync();
}
19
Source : TestTestAllFieldTypeRepository.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public async void Get()
{
Mock<ILogger<TestAllFieldTypeRepository>> loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context);
TestAllFieldType enreplacedy = new TestAllFieldType();
enreplacedy.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
context.Set<TestAllFieldType>().Add(enreplacedy);
await context.SaveChangesAsync();
var record = await repository.Get(enreplacedy.Id);
record.Should().NotBeNull();
}
19
Source : TestTestAllFieldTypesNullableRepository.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public async void Get()
{
Mock<ILogger<TestAllFieldTypesNullableRepository>> loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);
TestAllFieldTypesNullable enreplacedy = new TestAllFieldTypesNullable();
enreplacedy.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
context.Set<TestAllFieldTypesNullable>().Add(enreplacedy);
await context.SaveChangesAsync();
var record = await repository.Get(enreplacedy.Id);
record.Should().NotBeNull();
}
19
Source : TestTestAllFieldTypesNullableRepository.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public async void Create()
{
Mock<ILogger<TestAllFieldTypesNullableRepository>> loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);
var enreplacedy = new TestAllFieldTypesNullable();
enreplacedy.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
await repository.Create(enreplacedy);
var records = await context.Set<TestAllFieldTypesNullable>().ToListAsync();
records.Count.Should().Be(2);
}
19
Source : TestTestAllFieldTypeRepository.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public async void Create()
{
Mock<ILogger<TestAllFieldTypeRepository>> loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context);
var enreplacedy = new TestAllFieldType();
enreplacedy.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
await repository.Create(enreplacedy);
var records = await context.Set<TestAllFieldType>().ToListAsync();
records.Count.Should().Be(2);
}
19
Source : TestTestAllFieldTypeRepository.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public async void Update_Enreplacedy_Is_Not_Tracked()
{
Mock<ILogger<TestAllFieldTypeRepository>> loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context);
TestAllFieldType enreplacedy = new TestAllFieldType();
enreplacedy.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
context.Set<TestAllFieldType>().Add(enreplacedy);
await context.SaveChangesAsync();
context.Entry(enreplacedy).State = EnreplacedyState.Detached;
await repository.Update(enreplacedy);
var records = await context.Set<TestAllFieldType>().ToListAsync();
records.Count.Should().Be(2);
}
19
Source : TestTestAllFieldTypeRepository.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public async void DeleteFound()
{
Mock<ILogger<TestAllFieldTypeRepository>> loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context);
TestAllFieldType enreplacedy = new TestAllFieldType();
enreplacedy.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
context.Set<TestAllFieldType>().Add(enreplacedy);
await context.SaveChangesAsync();
await repository.Delete(enreplacedy.Id);
var records = await context.Set<TestAllFieldType>().ToListAsync();
records.Count.Should().Be(1);
}
19
Source : TestTestAllFieldTypesNullableRepository.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public async void Update_Enreplacedy_Is_Tracked()
{
Mock<ILogger<TestAllFieldTypesNullableRepository>> loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);
TestAllFieldTypesNullable enreplacedy = new TestAllFieldTypesNullable();
enreplacedy.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
context.Set<TestAllFieldTypesNullable>().Add(enreplacedy);
await context.SaveChangesAsync();
var record = await repository.Get(enreplacedy.Id);
await repository.Update(record);
var records = await context.Set<TestAllFieldTypesNullable>().ToListAsync();
records.Count.Should().Be(2);
}
19
Source : TestTestAllFieldTypesNullableRepository.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public async void Update_Enreplacedy_Is_Not_Tracked()
{
Mock<ILogger<TestAllFieldTypesNullableRepository>> loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);
TestAllFieldTypesNullable enreplacedy = new TestAllFieldTypesNullable();
enreplacedy.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
context.Set<TestAllFieldTypesNullable>().Add(enreplacedy);
await context.SaveChangesAsync();
context.Entry(enreplacedy).State = EnreplacedyState.Detached;
await repository.Update(enreplacedy);
var records = await context.Set<TestAllFieldTypesNullable>().ToListAsync();
records.Count.Should().Be(2);
}
19
Source : TestApiTestAllFieldTypeServerModelMapper.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public void MapServerRequestToResponse()
{
var mapper = new ApiTestAllFieldTypeServerModelMapper();
var model = new ApiTestAllFieldTypeServerRequestModel();
model.SetProperties(1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
ApiTestAllFieldTypeServerResponseModel response = mapper.MapServerRequestToResponse(1, model);
response.Should().NotBeNull();
response.FieldBigInt.Should().Be(1);
response.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldBit.Should().Be(true);
response.FieldChar.Should().Be("A");
response.FieldDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
response.FieldDecimal.Should().Be(1m);
response.FieldFloat.Should().Be(1);
response.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldMoney.Should().Be(1m);
response.FieldNChar.Should().Be("A");
response.FieldNText.Should().Be("A");
response.FieldNumeric.Should().Be(1m);
response.FieldNVarchar.Should().Be("A");
response.FieldReal.Should().Be(1m);
response.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldSmallInt.Should().Be(1);
response.FieldSmallMoney.Should().Be(1m);
response.FieldText.Should().Be("A");
response.FieldTime.Should().Be(TimeSpan.Parse("01:00:00"));
response.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldTinyInt.Should().Be(1);
response.FieldUniqueIdentifier.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
response.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldVarchar.Should().Be("A");
response.FieldXML.Should().Be("A");
}
19
Source : TestApiTestAllFieldTypesNullableServerModelMapper.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public void CreatePatch()
{
var mapper = new ApiTestAllFieldTypesNullableServerModelMapper();
var model = new ApiTestAllFieldTypesNullableServerRequestModel();
model.SetProperties(1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
JsonPatchDoreplacedent<ApiTestAllFieldTypesNullableServerRequestModel> patch = mapper.CreatePatch(model);
var response = new ApiTestAllFieldTypesNullableServerRequestModel();
patch.ApplyTo(response);
response.FieldBigInt.Should().Be(1);
response.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldBit.Should().Be(true);
response.FieldChar.Should().Be("A");
response.FieldDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
response.FieldDecimal.Should().Be(1m);
response.FieldFloat.Should().Be(1);
response.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldMoney.Should().Be(1m);
response.FieldNChar.Should().Be("A");
response.FieldNText.Should().Be("A");
response.FieldNumeric.Should().Be(1m);
response.FieldNVarchar.Should().Be("A");
response.FieldReal.Should().Be(1m);
response.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldSmallInt.Should().Be(1);
response.FieldSmallMoney.Should().Be(1m);
response.FieldText.Should().Be("A");
response.FieldTime.Should().Be(TimeSpan.Parse("01:00:00"));
response.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldTinyInt.Should().Be(1);
response.FieldUniqueIdentifier.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
response.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldVarchar.Should().Be("A");
response.FieldXML.Should().Be("A");
}
19
Source : TestApiTestAllFieldTypeServerModelMapper.cs
with MIT License
from codenesium
with MIT License
from codenesium
[Fact]
public void MapServerResponseToRequest()
{
var mapper = new ApiTestAllFieldTypeServerModelMapper();
var model = new ApiTestAllFieldTypeServerResponseModel();
model.SetProperties(1, 1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
ApiTestAllFieldTypeServerRequestModel response = mapper.MapServerResponseToRequest(model);
response.Should().NotBeNull();
response.FieldBigInt.Should().Be(1);
response.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldBit.Should().Be(true);
response.FieldChar.Should().Be("A");
response.FieldDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
response.FieldDecimal.Should().Be(1m);
response.FieldFloat.Should().Be(1);
response.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldMoney.Should().Be(1m);
response.FieldNChar.Should().Be("A");
response.FieldNText.Should().Be("A");
response.FieldNumeric.Should().Be(1m);
response.FieldNVarchar.Should().Be("A");
response.FieldReal.Should().Be(1m);
response.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
response.FieldSmallInt.Should().Be(1);
response.FieldSmallMoney.Should().Be(1m);
response.FieldText.Should().Be("A");
response.FieldTime.Should().Be(TimeSpan.Parse("01:00:00"));
response.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldTinyInt.Should().Be(1);
response.FieldUniqueIdentifier.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
response.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
response.FieldVarchar.Should().Be("A");
response.FieldXML.Should().Be("A");
}
See More Examples