blob: 6389192028d33f56b2c52dc6cbfbae4343c20db7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Text;
using System.Runtime.InteropServices;
using TestLibrary;
public struct DateWrapper
{
public DateTime date;
}
class NativeDateTime
{
[DllImport(nameof(NativeDateTime))]
public static extern DateTime GetTomorrow(DateTime today);
[DllImport(nameof(NativeDateTime))]
public static extern void GetTomorrowByRef(DateTime today, out DateTime tomorrow);
[DllImport(nameof(NativeDateTime))]
public static extern DateWrapper GetTomorrowWrapped(DateWrapper today);
}
class DateTimeTest
{
static int Main(string[] args)
{
try
{
DateTime currentDate = new DateTime(2019, 5, 2);
Assert.AreEqual(currentDate.AddDays(1), NativeDateTime.GetTomorrow(currentDate));
NativeDateTime.GetTomorrowByRef(currentDate, out DateTime nextDay);
Assert.AreEqual(currentDate.AddDays(1), nextDay);
DateWrapper wrapper = new DateWrapper { date = currentDate };
Assert.AreEqual(currentDate.AddDays(1), NativeDateTime.GetTomorrowWrapped(wrapper).date);
}
catch (Exception e)
{
Console.WriteLine($"Test Failure: {e}");
return 101;
}
return 100;
}
}
|