pub struct MockUuid { /* private fields */ }Expand description
Mock UUID provider for testing.
Can generate sequential UUIDs or return predetermined values.
Implementations§
Source§impl MockUuid
impl MockUuid
Sourcepub fn sequential() -> Self
pub fn sequential() -> Self
Create a mock UUID provider that generates sequential UUIDs.
The first UUID will be 00000000-0000-0000-0000-000000000001.
§Example
use xerv_core::testing::MockUuid;
use xerv_core::testing::UuidProvider;
let provider = MockUuid::sequential();
let id1 = provider.new_v4();
let id2 = provider.new_v4();
assert_eq!(id1.to_string(), "00000000-0000-0000-0000-000000000001");
assert_eq!(id2.to_string(), "00000000-0000-0000-0000-000000000002");Sourcepub fn sequential_from(start: u64) -> Self
pub fn sequential_from(start: u64) -> Self
Create a mock UUID provider that generates sequential UUIDs starting at the given value.
Sourcepub fn predetermined(uuids: Vec<Uuid>) -> Self
pub fn predetermined(uuids: Vec<Uuid>) -> Self
Create a mock UUID provider that returns predetermined UUIDs.
UUIDs are returned in the order provided. If more UUIDs are requested than provided, sequential UUIDs are generated starting from 1.
§Example
use xerv_core::testing::MockUuid;
use xerv_core::testing::UuidProvider;
use uuid::Uuid;
let id = Uuid::parse_str("12345678-1234-1234-1234-123456789abc").unwrap();
let provider = MockUuid::predetermined(vec![id]);
assert_eq!(provider.new_v4(), id);
// Next call returns sequential UUID (starting from 1)
assert_eq!(provider.new_v4().to_string(), "00000000-0000-0000-0000-000000000001");Sourcepub fn from_strings(uuids: &[&str]) -> Self
pub fn from_strings(uuids: &[&str]) -> Self
Create a mock UUID provider from string representations.
§Panics
Panics if any string is not a valid UUID.
Sourcepub fn current_counter(&self) -> Option<u64>
pub fn current_counter(&self) -> Option<u64>
Get the current sequential counter value (for debugging).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MockUuid
impl !RefUnwindSafe for MockUuid
impl Send for MockUuid
impl Sync for MockUuid
impl Unpin for MockUuid
impl UnwindSafe for MockUuid
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.