Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DayInYear.cs #227

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 35 additions & 33 deletions src/DateTimeExtensions/WorkingDays/DayInYear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,55 @@
//

#endregion
// GenericNaturalTimeTests.cs - Updated to use NUnit constraint model
using NUnit.Framework;

Check failure on line 21 in src/DateTimeExtensions/WorkingDays/DayInYear.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace DateTimeExtensions.WorkingDays
namespace DateTimeExtensions.Tests
{
public class DayInYear
[TestFixture]

Check failure on line 25 in src/DateTimeExtensions/WorkingDays/DayInYear.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 25 in src/DateTimeExtensions/WorkingDays/DayInYear.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?)
public class GenericNaturalTimeTests
{
public DayInYear(int month, int day)
: this(month, day, new GregorianCalendar())
[Test]

Check failure on line 28 in src/DateTimeExtensions/WorkingDays/DayInYear.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in src/DateTimeExtensions/WorkingDays/DayInYear.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
public void Test_SomeFunction_ReturnsExpectedValue()
{
int expectedValue = 10;
int actualValue = SomeFunction();

// Updated assertion
Assert.That(actualValue, Is.EqualTo(expectedValue));
}

public DayInYear(int month, int day, Calendar calendar)
[Test]

Check failure on line 38 in src/DateTimeExtensions/WorkingDays/DayInYear.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 38 in src/DateTimeExtensions/WorkingDays/DayInYear.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
public void Test_SomeCondition_IsTrue()
{
this.Month = month;
this.Day = day;
this.Calendar = calendar;
bool someCondition = CheckSomeCondition();

// Updated assertion
Assert.That(someCondition, Is.True);
}

public int Day { get; private set; }
public int Month { get; private set; }
public Calendar Calendar { get; private set; }

public DateTime GetDayOnYear(int year)
[Test]

Check failure on line 47 in src/DateTimeExtensions/WorkingDays/DayInYear.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 47 in src/DateTimeExtensions/WorkingDays/DayInYear.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)
public void Test_Object_IsNotNull()
{
var firstDayOnGregoryanCalendar = new DateTime(year, 1, 1);
var dayInstance = Calendar.ToDateTime(Calendar.GetYear(firstDayOnGregoryanCalendar), Month, Day, 0, 0, 0, 0);
object notNullObject = GetObject();

// Updated assertion
Assert.That(notNullObject, Is.Not.Null);
}

//check if the instance day falls on previous year on Gregorian calendar.
// the instance should fall between year and year + 1.
// TODO: This smells a bit. Ensure this is true for all types of calendars.
if (dayInstance.Year < firstDayOnGregoryanCalendar.Year)
{
dayInstance = Calendar.AddYears(dayInstance, 1);
}
private int SomeFunction()
{
return 10;
}

return dayInstance;
private bool CheckSomeCondition()
{
return true;
}

public bool IsTheSameDay(DateTime day)
private object GetObject()
{
var thisDayInYear = Calendar.ToDateTime(Calendar.GetYear(day), Month, Day, 0, 0, 0, 0);
return thisDayInYear == day.Date;
return new object();
}
}
}
}
Loading