{"id":344303,"date":"2023-01-22T15:00:21","date_gmt":"2023-01-22T15:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=344303"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=344303","title":{"rendered":"<span>\u041f\u0440\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0427\u0430\u0441\u0442\u044c 2. Unit tests<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/bf5\/93b\/0e0\/bf593b0e0da1dd2072c467b8bd834137.jpg\" width=\"800\" height=\"512\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf5\/93b\/0e0\/bf593b0e0da1dd2072c467b8bd834137.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/711718\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u0431\u044b\u043b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u0439 \u0438 \u0442\u0435\u043c, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445, \u043a\u0430\u043a \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b, \u043e\u043d\u0438 \u0436\u0435 \u044e\u043d\u0438\u0442 (unit) \u0442\u0435\u0441\u0442\u044b. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 &#8212; \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0435\u0434\u0438\u043d\u0438\u0446 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c: \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u043b\u0430\u0441\u0441\u043e\u0432.\u00a0<\/p>\n<h2>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u044e\u0449\u0438\u0435 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 unit \u0442\u0435\u0441\u0442\u044b:<\/h2>\n<ul>\n<li>\n<p><strong>\u0411\u044b\u0441\u0442\u0440\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/strong>. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u044b\u0441\u044f\u0447\u0438 \u0438 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0442\u044b\u0441\u044f\u0447 \u0442\u0435\u0441\u0442\u043e\u0432. \u041f\u0440\u043e\u0433\u043e\u043d unit \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0443\u0434\u043e\u0437\u0430\u0442\u0440\u0430\u0442\u044b<\/strong>. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435<\/strong>. \u0422\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0441\u0440\u0435\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0441\u0435\u0442\u0438, \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u0442.\u043f.).<\/p>\n<\/li>\n<li>\n<p><strong>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435<\/strong>. \u041d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0438\u0437\u0432\u043d\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0435<\/strong>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442, \u043d\u0435 \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0435\u043d.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0435<\/strong>. \u0422\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b <em>\u043f\u0430\u0434\u0430\u0442\u044c<\/em> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442, \u0441\u043b\u043e\u043c\u0430\u043d\u0430 &#8212; \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0435 <em>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/em> &#8212; TDD, \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u201c<em>\u043a\u0440\u0430\u0441\u043d\u044b\u0435<\/em>\u201d, \u043d\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u201c<em>\u0437\u0435\u043b\u0435\u043d\u044b\u043c\u0438<\/em>\u201d (\u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c).<\/p>\n<\/li>\n<\/ul>\n<h2>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438:<\/h2>\n<ol>\n<li>\n<p><strong>\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. <\/strong>\u0414\u0443\u043c\u0430\u0439\u0442\u0435 \u043e \u0442\u0435\u0441\u0442\u0430\u0445 \u0435\u0449\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c TDD, \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u044c\u0442\u0435\u0441\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u044b\u043b\u0438 \u0432\u0438\u0434\u043d\u044b \u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0441\u043d\u0430\u0436\u0443\u0440\u0438. DI \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0442\u0430\u0442\u044c \u0432\u0430\u0448\u0438\u043c \u043b\u0443\u0447\u0448\u0438\u043c \u0434\u0440\u0443\u0433\u043e\u043c (DI \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0432\u0440\u043e\u0434\u0435 Dagger \u0438\u043b\u0438 Koin, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432).<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043d\u0435\u044f\u0432\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438 \u043c\u0430\u043f\u043f\u0435\u0440\u0430, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e.\u00a0<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">class LocationSelectionViewModelDelegate(private val mainScope: CoroutineScope) : LocationSelectionViewModel {  \u00a0\u00a0\u00a0private val repo: LocationRepository = LocationRepositoryImpl(Dispatchers.IO, LocationDataSourceImpl()) \u00a0\u00a0\u00a0private val locationItemMapper: LocationItemMapper = LocationItemMapper()  \u00a0\u2026  }<\/code><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f\u00a0 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0437\u0432\u043d\u0435:\u00a0<\/p>\n<pre><code class=\"kotlin\">class LocationSelectionViewModelDelegate( \u00a0\u00a0\u00a0private val mainScope: CoroutineScope, \u00a0\u00a0\u00a0private val repo: LocationRepository, \u00a0\u00a0\u00a0private val locationItemMapper: LocationItemMapper ) : LocationSelectionViewModel {  \u2026  }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<pre><code class=\"kotlin\">class LocationSelectionViewModelDelegateTest {  \u00a0\u00a0\u00a0private val testScope = TestScope() \u00a0\u00a0\u00a0private val locationRepository: LocationRepository = mock() \u00a0\u00a0\u00a0private val locationItemMapper: LocationItemMapper = mock() \u00a0\u00a0\u00a0private val delegate: LocationSelectionViewModelDelegate = \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0LocationSelectionViewModelDelegate(testScope, locationRepository, locationItemMapper)  \u00a0\u00a0\u00a0...  }<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p><strong>\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>. \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430: \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u043b\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.\u00a0<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440\u00a0<\/p>\n<pre><code class=\"kotlin\">fun `test incorrect input`() {  \u00a0\u00a0\u00a0\/\/ Arrange \u00a0\u00a0\u00a0val dateTimeItems = listOf(\"2023-01-01T00:00\")  \u00a0\u00a0\u00a0\/\/ Act \u00a0\u00a0\u00a0val mapped = mapper.map(dateTimeItems, null)  \u00a0\u00a0\u00a0\/\/ Assert \u00a0\u00a0\u00a0assertNull(mapped)  }<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0435 \u0442\u0430\u043a, \u043d\u0435 \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u044f \u0432 \u0441\u0430\u043c \u043a\u043e\u0434. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0436\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438.\u00a0<\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c:<\/p>\n<pre><code class=\"kotlin\">fun `map valid items with missing timezone to null`() {  \u00a0\u00a0\u00a0\/\/ Arrange \u00a0\u00a0\u00a0val dateTimeItems = listOf(\"2023-01-01T00:00\") \u00a0\u00a0\u00a0val timezone = null  \u00a0\u00a0\u00a0\/\/ Act \u00a0\u00a0\u00a0val mapped = mapper.map(dateTimeItems, timezone)  \u00a0\u00a0\u00a0\/\/ Assert \u00a0\u00a0\u00a0assertNull(mapped) }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044f\u0441\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u0436\u0435 \u043d\u0435 \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u044f \u0432 \u0441\u0430\u043c \u043a\u043e\u0434. \u0422\u0430\u043a\u0436\u0435, \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0430\u043c\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.\u00a0<\/p>\n<ol start=\"3\">\n<li>\n<p><strong>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/strong>. \u0422\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432: <strong>Arrange<\/strong>, <strong>Act<\/strong>, <strong>Assert<\/strong>.\u00a0<\/p>\n<ol>\n<li>\n<p>\u0412 \u0431\u043b\u043e\u043a\u0435 Arrange \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>Act \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>Assert &#8212; \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.\u00a0<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u041d\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0438 \u0447\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"kotlin\">fun `initial success state with no selection`() = testScope.runTest { \u00a0\u00a0\u00a0val testLocation = Location(id = \"0\", \"Test City\", Coordinate(30.0, 45.0), \"Test\/Zone\") \u00a0\u00a0\u00a0val testItem = LocationItem(testLocation, \"Test City\", false) \u00a0\u00a0\u00a0whenever(locationRepository.getLocations()).thenReturn(listOf(testLocation)) \u00a0\u00a0\u00a0whenever(locationItemMapper.map(testLocation, isSelected = false)).thenReturn(testItem) \u00a0\u00a0\u00a0var uiState: LocationSelectionUiState? = null \u00a0\u00a0\u00a0val observeUiStateJob = launch(UnconfinedTestDispatcher(testScheduler)) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delegate.uiState.collect { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0uiState = it \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0delegate.fetchData() \u00a0\u00a0\u00a0assertThat(uiState).isNotNull \u00a0\u00a0\u00a0assertThat(uiState).isInstanceOf(SuccessState::class.java) \u00a0\u00a0\u00a0with(uiState as SuccessState) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertThat(selectedItem).isEqualTo(-1) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertThat(locations).isEqualTo(listOf(testItem)) \u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0observeUiStateJob.cancel() }<\/code><\/pre>\n<p>\u042f\u0432\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442 \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"kotlin\">fun `initial success state with no selection`() = testScope.runTest {  \u00a0\u00a0\u00a0\/\/ Arrange \u00a0\u00a0\u00a0val testLocation = Location(id = \"0\", \"Test City\", Coordinate(30.0, 45.0), \"Test\/Zone\") \u00a0\u00a0\u00a0val testItem = LocationItem(testLocation, \"Test City\", false) \u00a0\u00a0\u00a0whenever(locationRepository.getLocations()).thenReturn(listOf(testLocation)) \u00a0\u00a0\u00a0whenever(locationItemMapper.map(testLocation, isSelected = false)).thenReturn(testItem) \u00a0\u00a0\u00a0var uiState: LocationSelectionUiState? = null  \u00a0\u00a0\u00a0\/\/ Act \u00a0\u00a0\u00a0val observeUiStateJob = launch(UnconfinedTestDispatcher(testScheduler)) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delegate.uiState.collect { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0uiState = it \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0delegate.fetchData()  \u00a0\u00a0\u00a0\/\/ Assert \u00a0\u00a0\u00a0assertThat(uiState).isNotNull \u00a0\u00a0\u00a0assertThat(uiState).isInstanceOf(SuccessState::class.java) \u00a0\u00a0\u00a0with(uiState as SuccessState) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertThat(selectedItem).isEqualTo(-1) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertThat(locations).isEqualTo(listOf(testItem)) \u00a0\u00a0\u00a0}     \u00a0\u00a0\u00a0observeUiStateJob.cancel() }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u0440\u043e\u0449\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 \u0442\u0435\u0441\u0442\u043e\u0432, \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b. \u0422\u0430\u043a\u0436\u0435 \u0432\u0430\u043c \u0441\u043a\u0430\u0436\u0443\u0442 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 code review \u0438\u043b\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<ol start=\"4\">\n<li>\n<p><strong>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b<\/strong>. Unit \u0442\u0435\u0441\u0442\u044b &#8212; \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0441\u0430\u043c\u0438\u043c \u043a\u043e\u0434\u043e\u043c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d\u0438 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u0432, \u043a\u0430\u043a \u0438 \u0441\u0430\u043c production \u043a\u043e\u0434. \u0423\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u043e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 (\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435\/\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u0443\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430, \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u043f\u0443\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438). \u041e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">@Test(expected = DateTimeParseException::class) fun `map incorrect datetime format throws an exception`() {    \/\/ Arrange    val dateTime = \"2023-01-0100:00\"    val dateTimeItems = listOf(dateTime)    val timezone = \"Europe\/London\"     \/\/ Act    mapper.map(dateTimeItems, timezone) }<\/code><\/pre>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<pre><code class=\"kotlin\">@Test(expected = DateTimeParseException::class) fun `map incorrect datetime format throws an exception`() {    \/\/ Arrange    val dateTimeWithMissingDivider = \"2023-01-0100:00\"    val dateTimeItems = listOf(dateTimeWithMissingDivider)    val timezone = \"Europe\/London\"     \/\/ Act    mapper.map(dateTimeItems, timezone) }<\/code><\/pre>\n<ol start=\"5\">\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/strong>. \u041a\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438 \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u0432\u0435\u0441\u0442\u0438 \u0432 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432: \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 Arrange \u0431\u043b\u043e\u043a, \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0431\u0435\u0437 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">class ForecastDataMapperTest {     @Test    fun `map correct input with 2 items to correct output with 2 items`() {        \/\/ Arrange        val mapper = ForecastDataMapper()        val correctForecastWith2Items = buildDefaultForecastApiResponse()         \/\/ Act        val mapped = mapper.map(correctForecastWith2Items)         \/\/ Assert        Assertions.assertThat(mapped).isNotNull        \/\/ Some mandatory checks        Assertions.assertThat(mapped!!.temperature.data.size).isEqualTo(2)    }     private fun buildDefaultForecastApiResponse(        lat: Double? = -33.87,        lon: Double? = 151.21,        generationTimeMillis: Double? = 0.55,        utcOffsetSeconds: Int? = 39600,        timezone: String? = \"Australia\/Sydney\",        timezoneAbbreviation: String? = \"AEDT\",        elevation: Double? = 658.0,        hourlyUnits: HourlyDataUnitsApiResponse? = buildDefaultHourlyUnits(),        hourlyData: HourlyDataApiResponse? = buildDefaultHourlyDataApiResponse(),    ): ForecastApiResponse {        return ForecastApiResponse().apply {            this.lat = lat            this.lon = lon            this.generationTimeMillis = generationTimeMillis            this.utcOffsetSeconds = utcOffsetSeconds            this.timezone = timezone            this.timezoneAbbreviation = timezoneAbbreviation            this.elevation = elevation            this.hourlyUnits = hourlyUnits            this.hourlyData = hourlyData        }    }     private fun buildDefaultHourlyUnits(        time: String? = \"iso8601\",        temperature: String? = \"\u00b0C\",        humidity: String? = \"%\",        precipitation: String? = \"mm\",        windSpeed: String? = \"km\/h\",        weatherCode: String? = \"wmo code\",    ): HourlyDataUnitsApiResponse {        return HourlyDataUnitsApiResponse().apply {            this.time = time            this.temperature = temperature            this.humidity = humidity            this.precipitation = precipitation            this.windSpeed = windSpeed            this.weatherCode = weatherCode        }    }     private fun buildDefaultHourlyDataApiResponse(        time: List&lt;String?>? = listOf(\"2023-01-22T00:00\", \"2023-01-22T01:00\"),        temperature: List&lt;Double?>? = listOf(14.4, 14.2),        humidity: List&lt;Int?>? = listOf(86, 87),        precipitation: List&lt;Double?>? = listOf(0.0, 1.4),        windSpeed: List&lt;Double?>? = listOf(3.1, 2.2),        weatherCode: List&lt;Int?>? = listOf(3, 80),    ): HourlyDataApiResponse {        return HourlyDataApiResponse().apply {            this.time = time            this.temperature = temperature            this.humidity = humidity            this.precipitation = precipitation            this.windSpeed = windSpeed            this.weatherCode = weatherCode        }    } } <\/code><\/pre>\n<ol start=\"6\">\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. <\/strong>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435<strong> <\/strong>\u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432 unit \u0442\u0435\u0441\u0442\u0430\u0445 (\u043d\u0435 \u0442\u0430\u043a \u0436\u0435\u0441\u0442\u043a\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0438\u0434\u0430\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f). \u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0442 unit \u0442\u0435\u0441\u0442\u043e\u0432, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043c\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043d\u0430 \u0441\u0430\u043c\u0438 \u0442\u0435\u0441\u0442\u0430 \ud83d\ude42<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">@Test fun `map valid input with few items correctly`() {    \/\/ Arrange    val dateTimeItems = listOf(1, 2, 3).map { \"2022-12-31T0$it:00\" }    val inputTimezone = \"Europe\/London\"     \/\/ Act    val mapped = mapper.map(dateTimeItems, inputTimezone)     \/\/ Assert    assertThat(mapped!!.size).isEqualTo(2) }<\/code><\/pre>\n<p>\u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0435 9, 24? \u041b\u0443\u0447\u0448\u0435 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"kotlin\">@Test fun `map valid input with few items correctly`() {    \/\/ Arrange    val dateTimeItems = listOf(\"2022-12-31T23:59\", \"2023-01-01T00:00\")    val inputTimezone = \"Europe\/London\"     \/\/ Act    val mapped = mapper.map(dateTimeItems, inputTimezone)     \/\/ Assert    assertThat(mapped!!.size).isEqualTo(2) } <\/code><\/pre>\n<ol start=\"7\">\n<li>\n<p><strong>\u0420\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>. Unit \u0442\u0435\u0441\u0442\u044b \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0425\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 (mocks, stubs, fakes), \u043e\u0434\u043d\u0430\u043a\u043e, \u0432 \u044d\u0442\u043e\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u043f\u043e\u0440\u043e\u0439 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043d\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 &#8212; \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043c\u0430\u043f\u043f\u0435\u0440\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0430\u043c \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u044b \u0441\u043b\u043e\u043c\u0430\u043d\u044b, \u043b\u0443\u0447\u0448\u0435 \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>locationItemMapper<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u0430<\/p>\n<pre><code class=\"kotlin\">private val testScope = TestScope() private val locationRepository: LocationRepository = mock() private val locationItemMapper: LocationItemMapper = mock()  private val delegate: LocationSelectionViewModelDelegate =    LocationSelectionViewModelDelegate(testScope, locationRepository, locationItemMapper)  @Test fun `initial success state with no selection`() = testScope.runTest {    \/\/ Arrange    val testLocation = Location(id = \"0\", \"Test City\", Coordinate(30.0, 45.0), \"Test\/Zone\")    val testItem = LocationItem(testLocation, \"Test City\", false)    whenever(locationRepository.getLocations()).thenReturn(listOf(testLocation))    whenever(locationItemMapper.map(testLocation, isSelected = false)).thenReturn(testItem)    var uiState: LocationSelectionUiState? = null     \/\/ Act    val observeUiStateJob = launch(UnconfinedTestDispatcher(testScheduler)) {        delegate.uiState.collect {            uiState = it        }    }    delegate.fetchData()     \/\/ Assert    assertThat(uiState).isNotNull    assertThat(uiState).isInstanceOf(SuccessState::class.java)    with(uiState as SuccessState) {        assertThat(selectedItem).isEqualTo(-1)        assertThat(locations).isEqualTo(listOf(testItem))    }     observeUiStateJob.cancel() } <\/code><\/pre>\n<ol start=\"8\">\n<li>\n<p><strong>\u0427\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u044c<\/strong>. \u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432 \u0441\u0430\u043c \u0442\u0435\u0441\u0442, \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u0432 \u0431\u043b\u043e\u043a\u0430\u0445 <code>@Before<\/code> \u0438 <code>@After<\/code>. \u041e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0438\u0445 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0430\u0436\u043d\u044b\u0445 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438. \u0418\u043d\u0430\u0447\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0442\u0435\u0441\u0442\u0430\u043c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0 \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u044d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0432\u044b\u0441\u0438\u0442 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432. (\u042d\u0442\u043e\u0442 \u043d\u0430\u0432\u044b\u043a \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0442\u0440\u0435\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0438 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 coding \u0441\u0435\u0441\u0441\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0441\u0440\u043e\u043a\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 \u0434\u043e\u0441\u043a\u0435 \u0438\u043b\u0438 \u0432 \u0431\u043b\u043e\u043a\u043d\u043e\u0442\u0435).<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">private lateinit var testItem: LocationItem private lateinit var testLocation: Location private lateinit var observeUiStateJob: Job  @Before fun setup() {    testItem = LocationItem(testLocation, \"Test City\", false)    whenever(locationItemMapper.map(testLocation, isSelected = false)).thenReturn(testItem) }  @After fun tearDown() {    observeUiStateJob.cancel() }  @Test fun `initial success state with no selection`() = testScope.runTest {    \/\/ Arrange    val testLocation = Location(id = \"0\", \"Test City\", Coordinate(30.0, 45.0), \"Test\/Zone\")    whenever(locationRepository.getLocations()).thenReturn(listOf(testLocation))    var uiState: LocationSelectionUiState? = null     \/\/ Act    observeUiStateJob = launch(UnconfinedTestDispatcher(testScheduler)) {        delegate.uiState.collect {            uiState = it        }    }    delegate.fetchData()     \/\/ Assert    assertThat(uiState).isNotNull    assertThat(uiState).isInstanceOf(SuccessState::class.java)    with(uiState as SuccessState) {        assertThat(selectedItem).isEqualTo(-1)        assertThat(locations).isEqualTo(listOf(testItem))    } } <\/code><\/pre>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u043e\u0434\u0430 \u0432 <code>setup<\/code>\/<code>tearDown<\/code> \u0431\u043b\u043e\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a\u043e \u0432\u0441\u0435\u043c (\u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443) \u0442\u0435\u0441\u0442\u043e\u0432, \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043d\u043e\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430 \u0438 \u0443\u0445\u0443\u0434\u0448\u0438\u0442\u044c \u0438\u0437 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e. \u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c: <\/p>\n<pre><code class=\"kotlin\">@Test fun `initial success state with no selection`() = testScope.runTest {    \/\/ Arrange    val testLocation = Location(id = \"0\", \"Test City\", Coordinate(30.0, 45.0), \"Test\/Zone\")    val testItem = LocationItem(testLocation, \"Test City\", false)    whenever(locationRepository.getLocations()).thenReturn(listOf(testLocation))    whenever(locationItemMapper.map(testLocation, isSelected = false)).thenReturn(testItem)    var uiState: LocationSelectionUiState? = null     \/\/ Act    val observeUiStateJob = launch(UnconfinedTestDispatcher(testScheduler)) {        delegate.uiState.collect {            uiState = it        }    }    delegate.fetchData()     \/\/ Assert    assertThat(uiState).isNotNull    assertThat(uiState).isInstanceOf(SuccessState::class.java)    with(uiState as SuccessState) {        assertThat(selectedItem).isEqualTo(-1)        assertThat(locations).isEqualTo(listOf(testItem))    }     observeUiStateJob.cancel() } <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0442\u0435\u0441\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b, \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u0438 \u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u044e\u0442.<\/p>\n<ol start=\"9\">\n<li>\n<p><strong>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/strong>. \u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 <code>Act<\/code>\/<code>Asset<\/code> \u0431\u043b\u043e\u043a\u043e\u0432 \u0432 unit \u0442\u0435\u0441\u0442\u0430\u0445 (\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e \u0432 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445). \u0415\u0441\u043b\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <code>Act<\/code> \u0431\u043b\u043e\u043a\u043e\u0432, \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0431\u043e\u043b\u044c\u0448\u043e\u0439\u00a0 \u0442\u0435\u0441\u0442 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445. \u0421\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0439 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.\u00a0<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u0441\u0442<\/p>\n<pre><code class=\"kotlin\">@Test fun `location selection success flow`() = testScope.runTest {    \/\/ Arrange    val testLocation1 = Location(id = \"1\", \"Test City 1\", Coordinate(30.0, 45.0), \"Test\/Zone1\")    val testLocation2 = Location(id = \"2\", \"Test City 2\", Coordinate(45.0, 30.0), \"Test\/Zone2\")    val testItem1 = LocationItem(testLocation1, \"Test City 1\", false)    val testItem2 = LocationItem(testLocation2, \"Test City 2\", false)    val testItem1Selected = LocationItem(testLocation1, \"Test City 1\", true)    val testItem2Selected = LocationItem(testLocation2, \"Test City 2\", true)     whenever(locationRepository.getLocations()).thenReturn(listOf(testLocation1, testLocation2))    whenever(locationItemMapper.map(testLocation1, isSelected = false)).thenReturn(testItem1)    whenever(locationItemMapper.map(testLocation2, isSelected = false)).thenReturn(testItem2)    whenever(locationItemMapper.map(testLocation2, isSelected = true)).thenReturn(        testItem2Selected    )    whenever(locationItemMapper.map(testLocation1, isSelected = true)).thenReturn(        testItem1Selected    )    var uiState: LocationSelectionUiState? = null     \/\/ Act    val observeUiStateJob = launch(UnconfinedTestDispatcher(testScheduler)) {        delegate.uiState.collect {            uiState = it        }    }    delegate.fetchData()    delegate.onSelectionActionButtonClick(testLocation2)     \/\/ Assert    assertThat(uiState).isNotNull    assertThat(uiState).isInstanceOf(SuccessState::class.java)    with(uiState as SuccessState) {        assertThat(selectedItem).isEqualTo(1)        assertThat(locations).isEqualTo(listOf(testItem1, testItem2Selected))    }     \/\/ Act    delegate.onSelectionActionButtonClick(testLocation1)     \/\/ Assert    assertThat(uiState).isNotNull    assertThat(uiState).isInstanceOf(SuccessState::class.java)    with(uiState as SuccessState) {        assertThat(selectedItem).isEqualTo(0)        assertThat(locations).isEqualTo(listOf(testItem1Selected, testItem2))    }     observeUiStateJob.cancel() } <\/code><\/pre>\n<p>\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u0443\u0436\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f unit \u0442\u0435\u0441\u0442\u043e\u043c, \u044d\u0442\u043e \u0443\u0436\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442, \u0442\u0430\u043a \u043b\u0443\u0447\u0448\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438\u043c \u0438\u043b\u0438 \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 unit \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0443, \u0442\u043e \u0431\u043b\u043e\u043a unit \u0442\u0435\u0441\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u0430\u043c\u044b\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u0432 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438. \u0421\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438\u0445 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0430\u043a, \u0438 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e \u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0438\u0434\u044b \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/712060\/\"> https:\/\/habr.com\/ru\/post\/712060\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/711718\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u0431\u044b\u043b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u0439 \u0438 \u0442\u0435\u043c, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445, \u043a\u0430\u043a \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b, \u043e\u043d\u0438 \u0436\u0435 \u044e\u043d\u0438\u0442 (unit) \u0442\u0435\u0441\u0442\u044b. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 &#8212; \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0435\u0434\u0438\u043d\u0438\u0446 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c: \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u043b\u0430\u0441\u0441\u043e\u0432.\u00a0<\/p>\n<h2>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u044e\u0449\u0438\u0435 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 unit \u0442\u0435\u0441\u0442\u044b:<\/h2>\n<ul>\n<li>\n<p><strong>\u0411\u044b\u0441\u0442\u0440\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/strong>. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u044b\u0441\u044f\u0447\u0438 \u0438 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0442\u044b\u0441\u044f\u0447 \u0442\u0435\u0441\u0442\u043e\u0432. \u041f\u0440\u043e\u0433\u043e\u043d unit \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0443\u0434\u043e\u0437\u0430\u0442\u0440\u0430\u0442\u044b<\/strong>. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435<\/strong>. \u0422\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0441\u0440\u0435\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0441\u0435\u0442\u0438, \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u0442.\u043f.).<\/p>\n<\/li>\n<li>\n<p><strong>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435<\/strong>. \u041d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0438\u0437\u0432\u043d\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0435<\/strong>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442, \u043d\u0435 \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0435\u043d.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0435<\/strong>. \u0422\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b <em>\u043f\u0430\u0434\u0430\u0442\u044c<\/em> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442, \u0441\u043b\u043e\u043c\u0430\u043d\u0430 &#8212; \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0435 <em>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/em> &#8212; TDD, \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u201c<em>\u043a\u0440\u0430\u0441\u043d\u044b\u0435<\/em>\u201d, \u043d\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u201c<em>\u0437\u0435\u043b\u0435\u043d\u044b\u043c\u0438<\/em>\u201d (\u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c).<\/p>\n<\/li>\n<\/ul>\n<h2>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438:<\/h2>\n<ol>\n<li>\n<p><strong>\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. <\/strong>\u0414\u0443\u043c\u0430\u0439\u0442\u0435 \u043e \u0442\u0435\u0441\u0442\u0430\u0445 \u0435\u0449\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c TDD, \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u044c\u0442\u0435\u0441\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u044b\u043b\u0438 \u0432\u0438\u0434\u043d\u044b \u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0441\u043d\u0430\u0436\u0443\u0440\u0438. DI \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0442\u0430\u0442\u044c \u0432\u0430\u0448\u0438\u043c \u043b\u0443\u0447\u0448\u0438\u043c \u0434\u0440\u0443\u0433\u043e\u043c (DI \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0432\u0440\u043e\u0434\u0435 Dagger \u0438\u043b\u0438 Koin, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432).<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043d\u0435\u044f\u0432\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438 \u043c\u0430\u043f\u043f\u0435\u0440\u0430, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e.\u00a0<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">class LocationSelectionViewModelDelegate(private val mainScope: CoroutineScope) : LocationSelectionViewModel {  \u00a0\u00a0\u00a0private val repo: LocationRepository = LocationRepositoryImpl(Dispatchers.IO, LocationDataSourceImpl()) \u00a0\u00a0\u00a0private val locationItemMapper: LocationItemMapper = LocationItemMapper()  \u00a0\u2026  }<\/code><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f\u00a0 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0437\u0432\u043d\u0435:\u00a0<\/p>\n<pre><code class=\"kotlin\">class LocationSelectionViewModelDelegate( \u00a0\u00a0\u00a0private val mainScope: CoroutineScope, \u00a0\u00a0\u00a0private val repo: LocationRepository, \u00a0\u00a0\u00a0private val locationItemMapper: LocationItemMapper ) : LocationSelectionViewModel {  \u2026  }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<pre><code class=\"kotlin\">class LocationSelectionViewModelDelegateTest {  \u00a0\u00a0\u00a0private val testScope = TestScope() \u00a0\u00a0\u00a0private val locationRepository: LocationRepository = mock() \u00a0\u00a0\u00a0private val locationItemMapper: LocationItemMapper = mock() \u00a0\u00a0\u00a0private val delegate: LocationSelectionViewModelDelegate = \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0LocationSelectionViewModelDelegate(testScope, locationRepository, locationItemMapper)  \u00a0\u00a0\u00a0...  }<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p><strong>\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>. \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430: \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u043b\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.\u00a0<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440\u00a0<\/p>\n<pre><code class=\"kotlin\">fun `test incorrect input`() {  \u00a0\u00a0\u00a0\/\/ Arrange \u00a0\u00a0\u00a0val dateTimeItems = listOf(\"2023-01-01T00:00\")  \u00a0\u00a0\u00a0\/\/ Act \u00a0\u00a0\u00a0val mapped = mapper.map(dateTimeItems, null)  \u00a0\u00a0\u00a0\/\/ Assert \u00a0\u00a0\u00a0assertNull(mapped)  }<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0435 \u0442\u0430\u043a, \u043d\u0435 \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u044f \u0432 \u0441\u0430\u043c \u043a\u043e\u0434. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0436\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438.\u00a0<\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c:<\/p>\n<pre><code class=\"kotlin\">fun `map valid items with missing timezone to null`() {  \u00a0\u00a0\u00a0\/\/ Arrange \u00a0\u00a0\u00a0val dateTimeItems = listOf(\"2023-01-01T00:00\") \u00a0\u00a0\u00a0val timezone = null  \u00a0\u00a0\u00a0\/\/ Act \u00a0\u00a0\u00a0val mapped = mapper.map(dateTimeItems, timezone)  \u00a0\u00a0\u00a0\/\/ Assert \u00a0\u00a0\u00a0assertNull(mapped) }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044f\u0441\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u0436\u0435 \u043d\u0435 \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u044f \u0432 \u0441\u0430\u043c \u043a\u043e\u0434. \u0422\u0430\u043a\u0436\u0435, \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0430\u043c\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.\u00a0<\/p>\n<ol start=\"3\">\n<li>\n<p><strong>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/strong>. \u0422\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432: <strong>Arrange<\/strong>, <strong>Act<\/strong>, <strong>Assert<\/strong>.\u00a0<\/p>\n<ol>\n<li>\n<p>\u0412 \u0431\u043b\u043e\u043a\u0435 Arrange \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>Act \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>Assert &#8212; \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.\u00a0<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u041d\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0438 \u0447\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"kotlin\">fun `initial success state with no selection`() = testScope.runTest { \u00a0\u00a0\u00a0val testLocation = Location(id = \"0\", \"Test City\", Coordinate(30.0, 45.0), \"Test\/Zone\") \u00a0\u00a0\u00a0val testItem = LocationItem(testLocation, \"Test City\", false) \u00a0\u00a0\u00a0whenever(locationRepository.getLocations()).thenReturn(listOf(testLocation)) \u00a0\u00a0\u00a0whenever(locationItemMapper.map(testLocation, isSelected = false)).thenReturn(testItem) \u00a0\u00a0\u00a0var uiState: LocationSelectionUiState? = null \u00a0\u00a0\u00a0val observeUiStateJob = launch(UnconfinedTestDispatcher(testScheduler)) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delegate.uiState.collect { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0uiState = it \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0delegate.fetchData() \u00a0\u00a0\u00a0assertThat(uiState).isNotNull \u00a0\u00a0\u00a0assertThat(uiState).isInstanceOf(SuccessState::class.java) \u00a0\u00a0\u00a0with(uiState as SuccessState) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertThat(selectedItem).isEqualTo(-1) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertThat(locations).isEqualTo(listOf(testItem)) \u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0observeUiStateJob.cancel() }<\/code><\/pre>\n<p>\u042f\u0432\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442 \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"kotlin\">fun `initial success state with no selection`() = testScope.runTest {  \u00a0\u00a0\u00a0\/\/ Arrange \u00a0\u00a0\u00a0val testLocation = Location(id = \"0\", \"Test City\", Coordinate(30.0, 45.0), \"Test\/Zone\") \u00a0\u00a0\u00a0val testItem = LocationItem(testLocation, \"Test City\", false) \u00a0\u00a0\u00a0whenever(locationRepository.getLocations()).thenReturn(listOf(testLocation)) \u00a0\u00a0\u00a0whenever(locationItemMapper.map(testLocation, isSelected = false)).thenReturn(testItem) \u00a0\u00a0\u00a0var uiState: LocationSelectionUiState? = null  \u00a0\u00a0\u00a0\/\/ Act \u00a0\u00a0\u00a0val observeUiStateJob = launch(UnconfinedTestDispatcher(testScheduler)) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delegate.uiState.collect { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0uiState = it \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0} \u00a0\u00a0\u00a0delegate.fetchData()  \u00a0\u00a0\u00a0\/\/ Assert \u00a0\u00a0\u00a0assertThat(uiState).isNotNull \u00a0\u00a0\u00a0assertThat(uiState).isInstanceOf(SuccessState::class.java) \u00a0\u00a0\u00a0with(uiState as SuccessState) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertThat(selectedItem).isEqualTo(-1) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0assertThat(locations).isEqualTo(listOf(testItem)) \u00a0\u00a0\u00a0}     \u00a0\u00a0\u00a0observeUiStateJob.cancel() }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u0440\u043e\u0449\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 \u0442\u0435\u0441\u0442\u043e\u0432, \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b. \u0422\u0430\u043a\u0436\u0435 \u0432\u0430\u043c \u0441\u043a\u0430\u0436\u0443\u0442 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 code review \u0438\u043b\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<ol start=\"4\">\n<li>\n<p><strong>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b<\/strong>. Unit \u0442\u0435\u0441\u0442\u044b &#8212; \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0441\u0430\u043c\u0438\u043c \u043a\u043e\u0434\u043e\u043c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d\u0438 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u0432, \u043a\u0430\u043a \u0438 \u0441\u0430\u043c production \u043a\u043e\u0434. \u0423\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u043e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 (\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435\/\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u0443\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430, \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u043f\u0443\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438). \u041e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">@Test(expected = DateTimeParseException::class) fun `map incorrect datetime format throws an exception`() {    \/\/ Arrange    val dateTime = \"2023-01-0100:00\"    val dateTimeItems = listOf(dateTime)    val timezone = \"Europe\/London\"     \/\/ Act    mapper.map(dateTimeItems, timezone) }<\/code><\/pre>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<pre><code class=\"kotlin\">@Test(expected = DateTimeParseException::class) fun `map incorrect datetime format throws an exception`() {    \/\/ Arrange    val dateTimeWithMissingDivider = \"2023-01-0100:00\"    val dateTimeItems = listOf(dateTimeWithMissingDivider)    val timezone = \"Europe\/London\"     \/\/ Act    mapper.map(dateTimeItems, timezone) }<\/code><\/pre>\n<ol start=\"5\">\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/strong>. \u041a\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438 \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u0432\u0435\u0441\u0442\u0438 \u0432 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432: \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 Arrange \u0431\u043b\u043e\u043a, \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0431\u0435\u0437 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">class ForecastDataMapperTest {     @Test    fun `map correct input with 2 items to correct output with 2 items`() {        \/\/ Arrange        val mapper = ForecastDataMapper()        val correctForecastWith2Items = buildDefaultForecastApiResponse()         \/\/ Act        val mapped = mapper.map(correctForecastWith2Items)         \/\/ Assert        Assertions.assertThat(mapped).isNotNull        \/\/ Some mandatory checks        Assertions.assertThat(mapped!!.temperature.data.size).isEqualTo(2)    }     private fun buildDefaultForecastApiResponse(        lat: Double? = -33.87,        lon: Double? = 151.21,        generationTimeMillis: Double? = 0.55,        utcOffsetSeconds: Int? = 39600,        timezone: String? = \"Australia\/Sydney\",        timezoneAbbreviation: String? = \"AEDT\",        elevation: Double? = 658.0,        hourlyUnits: HourlyDataUnitsApiResponse? = buildDefaultHourlyUnits(),        hourlyData: HourlyDataApiResponse? = buildDefaultHourlyDataApiResponse(),    ): ForecastApiResponse {        return ForecastApiResponse().apply {            this.lat = lat            this.lon = lon            this.generationTimeMillis = generationTimeMillis            this.utcOffsetSeconds = utcOffsetSeconds            this.timezone = timezone            this.timezoneAbbreviation = timezoneAbbreviation            this.elevation = elevation            this.hourlyUnits = hourlyUnits            this.hourlyData = hourlyData        }    }     private fun buildDefaultHourlyUnits(        time: String? = \"iso8601\",        temperature: String? = \"\u00b0C\",        humidity: String? = \"%\",        precipitation: String? = \"mm\",        windSpeed: String? = \"km\/h\",        weatherCode: String? = \"wmo code\",    ): HourlyDataUnitsApiResponse {        return HourlyDataUnitsApiResponse().apply {            this.time = time            this.temperature = temperature            this.humidity = humidity<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-344303","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=344303"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344303\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=344303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=344303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=344303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}