Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simoncropp/nodatime.bogus
Add support for NodaTime to Bogus.
https://github.com/simoncropp/nodatime.bogus
Last synced: 8 days ago
JSON representation
Add support for NodaTime to Bogus.
- Host: GitHub
- URL: https://github.com/simoncropp/nodatime.bogus
- Owner: SimonCropp
- License: mit
- Created: 2018-06-29T10:19:56.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T10:00:59.000Z (24 days ago)
- Last Synced: 2024-10-29T17:18:10.597Z (17 days ago)
- Language: C#
- Homepage:
- Size: 857 KB
- Stars: 14
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.txt
- Code of conduct: code_of_conduct.md
Awesome Lists containing this project
README
# NodaTime.Bogus
[![Build status](https://ci.appveyor.com/api/projects/status/5if48t86ivcnrits/branch/main?svg=true)](https://ci.appveyor.com/project/SimonCropp/NodaTime-Bogus)
[![NuGet Status](https://img.shields.io/nuget/v/NodaTime.Bogus.svg)](https://www.nuget.org/packages/NodaTime.Bogus/)Add support for [NodaTime](https://nodatime.org/) to [Bogus](https://github.com/bchavez/Bogus).
**See [Milestones](../../milestones?state=closed) for release notes.**
## NuGet package
https://nuget.org/packages/NodaTime.Bogus/
## Usage
This project extends `Faker` with `.Noda()`.
```cs
var faker = new Faker()
.RuleFor(u => u.Property1, (f, _) => f.Noda().Duration())
.RuleFor(u => u.Property2, (f, _) => f.Noda().Instant.Recent())
.RuleFor(u => u.Property3, (f, _) => f.Noda().ZonedDateTime.Future());var target = faker.Generate();
Debug.WriteLine(target.Property1);
Debug.WriteLine(target.Property2);
Debug.WriteLine(target.Property3);
```
snippet source | anchorThere are several top level generators:
* `CalendarSystem()`: Creates a random [CalendarSystem](https://nodatime.org/unstable/api/NodaTime.CalendarSystem.html).
* `DateTimeZone()`: Creates a random [DateTimeZone](https://nodatime.org/unstable/api/NodaTime.DateTimeZone.html).
* `Duration()`: Creates a random [Duration](https://nodatime.org/unstable/api/NodaTime.Duration.html).
* `IsoDayOfWeek()`: Creates a random [IsoDayOfWeek](https://nodatime.org/unstable/api/NodaTime.IsoDayOfWeek.html).
* `Offset()`: Creates a random [Offset](https://nodatime.org/unstable/api/NodaTime.Offset.html).
* `Period()`: Creates a random [Period](https://nodatime.org/unstable/api/NodaTime.Period.html).
* `PeriodUnits()`: Creates a random [PeriodUnits](https://nodatime.org/unstable/api/NodaTime.PeriodUnits.html).There are several nested generators that provide `Past`, `Soon`, `Future`, `Between`, and `Recent` semantics:
* `.Instant`: Generators for [Instant](https://nodatime.org/unstable/api/NodaTime.Instant.html)
* `.LocalDate`: Generators for [LocalDate](https://nodatime.org/unstable/api/NodaTime.LocalDate.html)
* `.LocalDateTime`: Generators for [LocalDateTime](https://nodatime.org/unstable/api/NodaTime.LocalDateTime.html)
* `.LocalTime`: Generators for [LocalTime](https://nodatime.org/unstable/api/NodaTime.LocalTime.html)
* `.ZonedDateTime`: Generators for [ZonedDateTime](https://nodatime.org/unstable/api/NodaTime.ZonedDateTime.html)## Icon
[Calendar](https://thenounproject.com/term/calendar/689871/) designed by [Monster Critic](https://thenounproject.com/monstercritic/) from [The Noun Project](https://thenounproject.com/monstercritic/).